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