#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e3 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n;
bitset<maxn>dpl[maxn], dpr[maxn], wins[maxn];
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for(int i = 2; i <= n; i++)
	{
		string s;
		cin >> s;
		for(int j = 1; j <= sz(s); j++)
		{
			if(s[j - 1] == '0')
			{
				wins[i][j] = 0;
				wins[j][i] = 1;
			}
			else
			{
				wins[i][j] = 1;
				wins[j][i] = 0;
			}
		}
	}
	for(int i = 1; i <= n; i++)
		dpl[i][i] = dpr[i][i] = 1;
	for(int len = 2; len <= n; len++)
	{
		for(int i = len; i <= n; i++)
		{
			if((dpr[i - 1] & dpl[i - len + 1] & wins[i]).any())
				dpl[i - len + 1][i] = 1;
		}
		for(int i = n - len + 1; i >= 1; i--)
		{
			if((dpl[i + 1] & dpr[i + len - 1] & wins[i]).any())
				dpr[i + len - 1][i] = 1;
		}
	}
	cout << (dpl[1] & dpr[n]).count() << "\n";
	return 0;
}