#include<bits/stdc++.h>
#define maxn 2010
using namespace std;
bitset<maxn> g[2][maxn], mp[maxn], now, pre, suf;
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i - 1; j++)
		{
			char c = getchar();
			while (c != '0' && c != '1') c = getchar();
			mp[i][j] = c - '0';
			mp[j][i] = 1 - mp[i][j];
		}
	for (int i = 1; i <= n - 1; i++)
		g[0][i][i + 1] = g[1][i + 1][i] = 1;
	for (int len = 3; len <= n; len++)
		for (int i = 1; i <= n - len + 1; i++)
		{
			int j = i + len - 1;
			now = g[0][i] & g[1][j] & (mp[i] | mp[j]);
			if (now.count()) g[0][i][j] = g[1][j][i] = 1;
		}
	pre[1] = 1;
	for (int i = 2; i <= n; i++)
		for (int j = 1; j <= i - 1; j++)
			if (pre[j] & g[0][j][i] & mp[i][j]) pre[i] = 1;
	suf[n] = 1;
	for (int i = n - 1; i >= 1; i--)
		for (int j = i + 1; j <= n; j++)
			if (suf[j] & g[0][i][j] & mp[i][j]) suf[i] = 1;
	int res = 0;
	for (int i = 1; i <= n; i++)
		if (pre[i] & suf[i]) res++;
	printf("%d\n", res);
	return 0;
}