import java.util.*; public class Main { static long[] snacks; static long[][] dp; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); snacks = new long[n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { snacks[i] += sc.nextLong(); } } 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]; } }