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