package 测试;
import java.util.Scanner;
public class 圣诞礼物2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,j,k;
Scanner input=new Scanner(System.in);
while(input.hasNext()) {
int M=input.nextInt();
int N=input.nextInt();
int [][]MN=new int [M][N];
int [][]Darg=new int[M][N];
for(i=0;i<Darg.length;i++) {
for(j=0;j<Darg[i].length;j++) {
Darg[i][j]=input.nextInt();
}
}
x1(Darg,MN);
x2(Darg,MN);
System.out.println(x3(MN));
}
}
public static void x1(int [][]darg,int [][]mn) {
int i,j,k;
mn[0][0]=darg[0][0];
for(i=1;i<darg[0].length;i++)
mn[0][i]=darg[0][i]+mn[0][i-1];
for(i=1;i<darg.length;i++)
mn[i][0]=darg[i][0]+mn[i-1][0];
}
public static void x2(int [][]darg1,int [][]mn1) {
int i,j,k;
for(i=1;i<mn1.length;i++) {
for(j=1;j<mn1[i].length;j++) {
if(mn1[i-1][j]>=mn1[i][j-1])
mn1[i][j]=mn1[i-1][j]+darg1[i][j];
else
mn1[i][j]=mn1[i][j-1]+darg1[i][j];
}
}
}
public static int x3(int [][]mn2) {
int i,j,k;
int temp=mn2[0][0];
for(i=0;i<mn2.length;i++) {
for(j=0;j<mn2[i].length;j++) {
if(mn2[i][j]>temp)
temp=mn2[i][j];
}
}
return temp;
}
}