import java.util.*; import java.io.*; public class Main { static long[] snacks; static long[][] dp; public static void main (String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); snacks = new long[n]; for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" ", m); for (int j = 0; j < m; j++) { snacks[i] += Long.parseLong(line[j]); } } dp = new long[n][2]; for (long[] arr : dp) { Arrays.fill(arr, Long.MIN_VALUE / 10); } System.out.println(Math.max(dfw(n - 1, 0), dfw(n - 1, 1))); } static long dfw(int idx, int evod) { if (idx < 0) { if (evod == 0) { return 0; } else { return Long.MIN_VALUE / 10; } } if (dp[idx][evod] == Long.MIN_VALUE / 10) { if (evod == 0) { dp[idx][evod] = Math.max(dfw(idx - 1, 0), dfw(idx - 1, 1) - snacks[idx]); } else { dp[idx][evod] = Math.max(dfw(idx - 1, 1), dfw(idx - 1, 0) + snacks[idx]); } } return dp[idx][evod]; } }