n,m = map(int,input().split()) cum = [] for i in range(n): cum.append(sum(map(int,input().split()))) dp = [[0]*2 for i in range(n+1)] for i in range(n): dp[i+1][0] = max(dp[i][0],dp[i][1]+cum[i]) dp[i+1][1] = max(dp[i][1],dp[i][0]-cum[i]) print(max(dp[-1]))