fun main(args:Array<String>):Unit {
    var (r, c) = readLine()!!.split(' ').map(String::toInt)
    while (r != 0 && c != 0){
        val senbei = Array(r){readLine()!!.trim().split(' ').map(String::toInt).toIntArray()}.let{a ->
            (0 until c).map{x -> (0 until r).map{y -> a[y][x]}.fold(0){p, i -> p * 2 + i}}
        }
        var max = 0
        for (i in 0 until (1 shl r)){
            max = senbei.sumBy {
                countOne(it xor i).let{
                    if (it * 2 > r){
                        it
                    }else{
                        r - it
                    }
                }
            }.let{if (it > max) it else max}
        }
        println(max)
        val (nr, nc) = readLine()!!.split(' ').map(String::toInt)
        r = nr
        c = nc
    }
}
fun countOne(n:Int):Int {
    return when(n){
        0 -> 0
        else -> n % 2 + countOne(n / 2)
    }
}
