n = int(input())
m = int(input())
jiange = 0
ludi = 0
for i in range(n):
    nlb = input()
    nlb = [int(i) for i in nlb]
for j in nlb:
    if nlb[j] == 0 and nlb[j+1] == 1
        jiange = jiange+1
    if nlb[j] == 1:
        ludi = ludi+1
print(ludi-jiange)
            
            
