s=input().split(' ')
n=int(s[0])
m=int(s[1])
l=[]
a=0
b=0
c=0
d=0
for i in range(n):
    l.append([input()])
for i in range(n):
    for j in range(m):
        if l[i][j]=='0':
            if a!=i:
                a=i
                b=j
            else:
                c=i
                d=j
if a>c:
    x=a-c
elif c>a:
    x=c-a
else:
    x=0
if b>d:
    y=b-d
elif d>b:
    y=d-b
else:
    y=0
print(n*m-(x+y+1))
