# coding: utf-8 # Your code here! N,M=map(int,input().split()) A=[] for i in range(N): temp=list(map(int,input().split())) A.append(sum(temp)) dp=[0,0] for a in A: dp[0],dp[1]=max(dp[1]-a,dp[0]),max(dp[0]+a,dp[1]) #print(A) print(max(dp))