from typing import List def yuki1060(grid: List[List[int]]) -> int: ROW, COL = len(grid), len(grid[0]) colSum = [0] * COL for i in range(ROW): for j in range(COL): colSum[j] += grid[i][j] rowPrice = [0] * ROW for i in range(ROW): for j in range(COL): rowPrice[i] += grid[i][j] * colSum[j] rowPrice.sort(reverse=True) res1 = sum(rowPrice[::2]) res2 = sum(rowPrice[1::2]) return res1 - res2 if __name__ == "__main__": n, m = map(int, input().split()) grid = [list(map(int, input().split())) for _ in range(n)] print(yuki1060(grid))