n, m = map(int, input().split()) A = [] for _ in range(n): B = list(map(int, input().split())) A.append(sum(B)) INF = 10**18 DP = [[-INF for _ in range(2)] for _ in range(n + 1)] DP[0][0] = 0 for i in range(n): DP[i + 1][1] = max(DP[i + 1][1], DP[i][1], DP[i][0] + A[i]) DP[i + 1][0] = max(DP[i + 1][0], DP[i][0], DP[i][1] - A[i]) print(max(DP[n]))