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