N,M = map(int,input().split()) A = [] for _ in range(N): A.append(sum(list(map(int,input().split())))) ans = 0 if N == 1: print(A[0]) exit() ac_1 = [A[0]] for i in range(1,N): if i%2 == 0: ac_1.append(ac_1[-1]+A[i]) else: ac_1.append(ac_1[-1]-A[i]) ac_2 = [A[1]] for i in range(2,N): if i%2 != 0: ac_2.append(ac_2[-1]+A[i]) else: ac_2.append(ac_2[-1]-A[i]) ac_1,ac_2 = [0]+ac_1,[0]+ac_2 for i in range(len(ac_1)): for j in range(i+1,len(ac_1)): ans = max(ans,ac_1[j]-ac_1[i]) for i in range(len(ac_2)): for j in range(i+1,len(ac_2)): ans = max(ans,ac_2[j]-ac_2[i]) print(ans)