#include <bits/stdc++.h>
using namespace std;
long long f[101][101];
int main() {
freopen("TST.INP","r",stdin);
freopen("TST.OUT","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n,k; cin >> k >> n;
for(int i=1;i<=k;i++) {
for(int j=1;j<=n;j++) {
long long x; cin >> x;
if(j>=i) f[i][j]=max(f[i][j-1],f[i-1][j-1]+x);
}
}
cout << f[k][n];
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmxvbmcgbG9uZyBmWzEwMV1bMTAxXTsKaW50IG1haW4oKSB7CiAgICBmcmVvcGVuKCJUU1QuSU5QIiwiciIsc3RkaW4pOwogICAgZnJlb3BlbigiVFNULk9VVCIsInciLHN0ZG91dCk7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKDApLCBjb3V0LnRpZSgwKTsKICAgIGludCBuLGs7IGNpbiA+PiBrID4+IG47CiAgICBmb3IoaW50IGk9MTtpPD1rO2krKykgewogICAgICAgIGZvcihpbnQgaj0xO2o8PW47aisrKSB7CiAgICAgICAgICAgIGxvbmcgbG9uZyB4OyBjaW4gPj4geDsKICAgICAgICAgICAgaWYoaj49aSkgZltpXVtqXT1tYXgoZltpXVtqLTFdLGZbaS0xXVtqLTFdK3gpOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgZltrXVtuXTsKICAgIHJldHVybiAwOwp9