### main

loop do
  rn, cn = gets.strip.split(' ').map{|s| s.to_i}
  break if (rn | cn) == 0

  sums = cn.times.map{0}
  an = []

  rn.times do
    ak =  gets.strip.split(' ').map{|s| s.to_i}
    an << ak

    for i in (0...cn)
      sums[i] += ak[i]
    end
  end
  #p sums

  max_bits = (1 << (rn - 1)) - 1
  max_ok = 0

  for bits in (0..max_bits)
    sums0 = sums.clone

    for b in (0...(rn - 1))
      if (bits & (1 << b)) != 0
        for i in (0...cn)
          sums0[i] += (an[b][i] == 0 ? 1 : -1)
        end
      end
    end

    ok = sums0.inject(0){|sum, s| sum + [s, rn - s].max}
    max_ok = ok if max_ok < ok
  end

  puts max_ok
end