N,M=map(int,input().split()) B=[0]*N for i in range(N): A=list(map(int,input().split())) B[i]=sum(A) DP=[[0,0] for _ in range(N+1)] for x in range(1,N+1): DP[x][0]=max(DP[x-1][0],DP[x-1][1]+B[x-1]) DP[x][1]=max(DP[x-1][0]-B[x-1],DP[x-1][1]) print(DP[-1][0])