#include<bits/stdc++.h>
using namespace std;
const int N=2000+5;
bitset<N> L[N],R[N],a[N];
signed main(){
	int n;char ch;
	cin>>n;
	for(int i=2;i<=n;++i)
		for(int j=1;j<i;++j){
			cin>>ch;
			a[i][j]=ch-'0';
			a[j][i]=(ch-'0')^1;
		}
	for(int i=1;i<=n;++i)
		L[i][i]=R[i][i]=1;
	for(int len=2;len<=n;++len)
		for(int i=1;i+len-1<=n;++i){
			int j=i+len-1;
			L[j][i]=(L[j]&R[i+1]&a[i]).count()!=0;
			R[i][j]=(L[j-1]&R[i]&a[j]).count()!=0;
		}
	int ans=0;
	for(int i=1;i<=n;++i)
		ans+=(L[n][i] & R[1][i]);
	cout<<ans;
	return 0;
}