i=input n=int(i()) m=int(i()) A=[list(map(int, i().split())) for _ in '1'*m] B=[0]*m for _ in range(n-1): new_B = [max([B[k]+A[k][j] for k in range(m)]) for j in range(m)] B = new_B print(max(new_B))