n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
f.close()

s = 0
for i in range(n - 1):
    for j in range(n - 1):
        if a[i][j] + a[i + 1][j] + a[i][j + 1] + a[i + 1][j + 1] == 13:
            s += 1
print(s)