loop do
    m, n = gets.split.map(&:to_i)
    break if m == 0
    rows = (1..n).map { gets.to_i(2) }
    if n == 1
        puts 0
        next
    end

    tests = rows.combination(2).map {|r1, r2| r1 ^ r2 }
    (1..2**m-1).sort_by{|x| x.to_s(2).count(?1)}.each do |x|
        if tests.all? {|t| x & t > 0}
            puts x.to_s(2).count(?1)
            break
        end
    end
end