#include <iostream>
#include <bitset>

using namespace std;

int n;
bitset<2005> a[2005], dp[2005];
bitset<2005> mask[2005], mask2[2005];

int main(void)
{
	cin >> n;
	char c;
	for(int i = 2; i <= n; i++){
		for(int j = 1; j < i; j++){
			cin >> c;
			a[i][j] = c-'0';
			a[j][i] = !a[i][j];
		}
	}
	
	for(int i = 1; i <= n; i++) dp[i][i] = 1;
	for(int len = 2; len <= n; len++){
		for(int l = 1; l <= n; l++){
			int r = l + len - 1;
			if(r > n) continue;
			mask[l][r-1] = 1;
			dp[l][r] = (a[r] & dp[l] & dp[r-1] & mask[l]).any();
			mask2[r][l+1] = 1;
			dp[r][l] = (a[l] & dp[l+1] & dp[r] & mask2[r]).any();
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(dp[1][i] && dp[n][i]) ans++;
	}
	cout << ans << endl;
	
	return 0;
}