import Control.Monad (replicateM_,forM_)
import Data.Bits (xor)
import Data.Array (Array,listArray,elems,(!))
import qualified Data.Array.IO as IOArr

type Row = Int
type Column = Int
type Table = Array Int Int

main = do
    [nr,nc] <- getLine >>= (return . map read . words)
    if all (==0) [nr,nc] then return () else do
        nums <- IOArr.newArray (1,nc) 0 :: IO (IOArr.IOArray Int Int)
        replicateM_ nr (getLine >>= update nums . map read . words)
        nums <- IOArr.freeze nums
        print $ solve nr nums
        main

    where
    update nums bs = forM_ (zip [1..] bs) update'
        where
        update' :: (Int,Int) -> IO ()
        update' (i,b) = do
            num <- IOArr.readArray nums i
            IOArr.writeArray nums i (2*num+b)

solve :: Int -> Table -> Int
solve nr nums = mbcs `seq` maximum $ map (countWith mbcs) [0..2^nr-1]
    where
    mbcs = maxBitCounts nr
    countWith mbcs i = sum $ map (\num -> mbcs ! (num `xor` i)) (elems nums)

maxBitCounts :: Int -> Array Int Int
maxBitCounts nr = listArray (0,2^nr-1) (map maxBitCount [0..2^nr-1])
    where
    maxBitCount n = bc `seq` max bc (nr - bc)
        where
        bc = bitCount n

    bitCount 0 = 0
    bitCount n = (n `mod` 2) + bitCount (n `div` 2)