import java.util.ArrayList;
import java.util.Scanner;
public class Main{
public static class Point{
public int x;
public int y;
public Point(int x, int y){
this.x = x;
this.y = y;
}
public boolean isNear(Point p){
if (Math.abs(this.x - p.x)<=1 && Math.abs(this.y - p.y)<=1) {
return true;
}
return false;
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int n = in.nextInt();
int[][] a = new int[n][n];
for(int i=0; i<n; i++){
for(int j=0; j<a[i].length; j++){
if (in.next().equals("0")) {
a[i][j] = 0;
}else {
a[i][j] = 1;
}
}
}
System.out.println(getNum(a));
}
}
private static int getNum(int[][] a){
ArrayList<Point> points = new ArrayList<Point>();
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
if (a[i][j]!=0) {
points.add(new Point(i, j));
}
}
}
int res = 0;
for(int i=0; i<points.size(); i++){
boolean flag = false;
for(int j=0; j<i; j++){
if (points.get(i).isNear(points.get(j))) {
flag = true;
break;
}
}
if (!flag) {
res++;
}
}
return res;
}
}
#阿里巴巴#