a=input().split()
n=int(a[0])
m=int(a[1])
b=[]
s=0
for d in range(n):
    c=input().split()
    b.append(int(c[d]))
for i in range(n):
    for j in range(m):
        if b[i][j]==1:
            s+=1
print(s-m)