require 'tapp'
require 'pp'

def reverse_row(row)
  row.map{|c| 1 - c }
end

def print_field(field)
  field.each do |row|
    puts row.join(' ')
  end
  puts '-----'
end

while line = gets
  row, col = line.split(' ').map(&:to_i)
  break if row == 0 and col == 0

  field = row.times.map{ gets.split(' ').map(&:to_i) }

  ans = -1

  0.upto(2 ** row - 1) do |i|
    field2 = field.map.with_index do |row, y|
      if i[y] == 1
        reverse_row(row)
      else
        row
      end
    end

    flatten_f2 = field2.flatten
    num_of_one = flatten_f2.count(1)
    if num_of_one < flatten_f2.size / 2
      field2 = field2.map{|row| reverse_row(row) }
    end

    # print_field field2

    col.times do |c|
      num_of_one = field2.count{|row| row[c] == 1 }
      if num_of_one <= row / 2
        field2 = field2.map{|row| row[c] = 1 - row[c]; row }
      end
    end

    # print_field field2
    # puts '==============='

    ans = [ans, field2.flatten.count(1)].max
  end

  puts ans
end