#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset>
using namespace std;
#define N 2002
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
char s[N];
bitset<N> dpL[N],dpR[N],a[N];
int main(){
	n=read();
	for(int i=2;i<=n;++i){
		scanf("%s",s+1);
		for(int j=1;j<i;++j){
			a[i][j]=s[j]-'0';
			a[j][i]=a[i][j]^1;
		}
	}
	for(int i=1;i<=n;++i){
		dpL[i][i]=dpR[i][i]=1;
	}
	for(int len=2;len<=n;++len){
		for(int l=1;l+len-1<=n;++l){
			int r=l+len-1;
			if((a[l]&dpR[l+1]&dpL[r]).any())dpL[r][l]=1;
			if((a[r]&dpR[l]&dpL[r-1]).any())dpR[l][r]=1;
		}
	}
	printf("%d\n",(int)(dpL[n]&dpR[1]).count());
	return 0;
}

