N,M = map(int,input().split()) A = [] for _ in range(N): A.append(sum(list(map(int,input().split())))) ans = max(A) if N == 1: print(ans) exit() dp = [[0 for _ in range(2)] for _ in range(N+1)] for i in range(N): dp[i+1][0] = max(dp[i][1]+A[i], dp[i][0]) dp[i+1][1] = max(dp[i][0]-A[i],dp[i][1]) print(max(dp[N]))