#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
ll R,C,K,r,c,v,g[3001][3001],a[3001][3001][4];

int main(){
	cin>>R>>C>>K;
	rep(i,K){cin>>r>>c>>v;g[r][c]=v;}
	rep(i,R)rep(j,C)rep(k,3)a[i][j][k]=max(a[i-1][j][3]+g[i][j],max(a[i][j-1][k-1]+g[i][j],a[i][j-1][k]));
	cout<<a[R][C][3]<<endl;
}
