INF = 10**18 N, M = map(int, input().split()) A = [sum(map(int, input().split())) for _ in range(N)] dp = [[-INF for j in range(N + 1)] for i in range(N + 1)] for i in range(N + 1): dp[i][0] = 0 for i in range(1, N + 1): for j in range(1, N + 1): if j % 2 == 0: dp[i][j] = max(dp[i][j], dp[i - 1][j], dp[i - 1][j - 1] - A[i - 1]) else: dp[i][j] = max(dp[i][j], dp[i - 1][j], dp[i - 1][j - 1] + A[i - 1]) print(max(dp[N]))