#include <bits/stdc++.h>
using namespace std;

const int N = 2005;

int n;
bitset<N> a[N], l[2][N], r[2][N], d[2][N];

int main(){
	scanf("%d", &n);
	for(int i = 2; i <= n; i++){
		for(int j = 1; j < i; j++){
			int x;
			scanf("%1d", &x);
			a[i][j] = x;
			a[j][i] = !x;
		}
	}
	for(int i = 1; i <= n; i++) l[1][i][i] = r[1][i][i] = d[1][i][i] = 1;
	for(int len = 2; len <= n; len++){
		for(int st = 1; st + len - 1 <= n; st++){
			l[len & 1][st] = l[~len & 1][st];
			l[len & 1][st][st + len - 1] = ((d[~len & 1][st] & a[st + len - 1]).count() != 0);
			r[len & 1][st] = r[~len & 1][st + 1];
			r[len & 1][st][st] = ((d[~len & 1][st + 1] & a[st]).count() != 0);
			d[len & 1][st] = l[len & 1][st] & r[len & 1][st];
		}
	}
	printf("%d\n", d[n & 1][1].count());
}