#include<bits/stdc++.h>

using namespace std;

#define N 2005

int n,ans;
bitset<N> a[N],f[N],g[N];
char s[N][N];

int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;++i){
		scanf("%s",s[i]+1);
		for (int j=1;j<i;++j){
			a[i][j]=s[i][j]-'0';
			a[j][i]=a[i][j]^1;
		}
	}
	for (int i=1;i<=n;++i){
		f[i][i]=g[i][i]=1;
		for (int j=1;j<i;++j)
			if (g[i-1][j]&&a[i][j]) f[i]|=f[j];
		for (int j=1;j<i;++j)
			if (f[i][j+1]&&a[j][i]) g[i]|=g[j];
	}
	for (int i=1;i<=n;++i) ans+=f[i][1]&&g[n][i];
	printf("%d\n",ans);
	
	return 0;
}
			