n,m=map(int,input().split()) a=b=0 for i in range(n): c=sum(map(int,input().split())) a+=max(b-c,0) b=c print(a+b)