#include<bits/stdc++.h>
#define ll long long
#define N 2010
using namespace std;
bitset<N> dpl[N],dpr[N],a[N];
int n,x,ansn;
char ch;
int main(){
	cin>>n;
	for (int i=2;i<=n;i++){
		for (int j=1;j<i;j++){
			cin>>ch;x=ch-'0';
			a[i][j]=x;a[j][i]=1-x;
		}
	}
	for (int i=1;i<=n;i++)dpl[i][i]=dpr[i][i]=1;
	for (int l=2;l<=n;l++){
		for (int i=1;i+l-1<=n;i++){
			if ((a[i]&dpl[i+l-1]&dpr[i+1]).any())dpl[i+l-1][i]=1;
			if ((a[i+l-1]&dpl[i+l-2]&dpr[i]).any())dpr[i][i+l-1]=1;
		}
	}
	cout<<((dpr[1]&dpl[n]).count())<<endl;
	return 0;
}