import sys

e = sys.stdin.readlines()

while 1:

 r=int(e[0].split()[0])

 if r<1:break

 d=[int(''.join(x),2)for x in zip(*[x.split() for x in e[1:r+1]])]

 a=[]

 for i in range(1<<r):

  b=0

  for j in d:

   c=bin(i^j).count('1')

   b+=c if c>r//2 else r-c

  a+=[b]

 print((max(a)))

 del e[:r+1]

for e in iter(input,'0 0'):

 r=int(e.split()[0])

 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]

 a=0

 b=1<<r

 f=[1]*b

 for m in range(b):

  if f[m]:

   f[~m]=0

   t=0

   for s in d:

    c=bin(m^s).count('1')

    t+=c if c>r//2 else r-c

   if a<t:a=t

 print(a)

import sys

e = sys.stdin.readlines()
while 1:
    r = int(e[0].split()[0])
    if r < 1:
        break
    d = [int("".join(x), 2) for x in zip(*[x.split() for x in e[1 : r + 1]])]
    a = []
    for i in range(1 << r):
        b = 0
        for j in d:
            c = bin(i ^ j).count("1")
            b += c if c > r // 2 else r - c
        a += [b]
    print((max(a)))
    del e[: r + 1]

for e in iter(input, "0 0"):
    r = int(e.split()[0])
    d = [int("".join(x), 2) for x in zip(*[input().split() for _ in [0] * r])]
    a = 0
    b = 1 << r
    f = [1] * b
    for m in range(b):
        if f[m]:
            f[~m] = 0
            t = 0
            for s in d:
                c = bin(m ^ s).count("1")
                t += c if c > r // 2 else r - c
            if a < t:
                a = t
    print(a)

-import sys - -e = sys.stdin.readlines() -while 1: -    r = int(e[0].split()[0]) -    if r < 1: -        break -    d = [int("".join(x), 2) for x in zip(*[x.split() for x in e[1 : r + 1]])] -    a = [] -    for i in range(1 << r): -        b = 0 -        for j in d: -            c = bin(i ^ j).count("1") -            b += c if c > r // 2 else r - c -        a += [b] -    print((max(a))) -    del e[: r + 1] +for e in iter(input, "0 0"): +    r = int(e.split()[0]) +    d = [int("".join(x), 2) for x in zip(*[input().split() for _ in [0] * r])] +    a = 0 +    b = 1 << r +    f = [1] * b +    for m in range(b): +        if f[m]: +            f[~m] = 0 +            t = 0 +            for s in d: +                c = bin(m ^ s).count("1") +                t += c if c > r // 2 else r - c +            if a < t: +                a = t +    print(a)