#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>
#include <bitset>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SZ = 2010;

ll n;
bitset<SZ> grid[SZ], msk[SZ];
bitset<SZ> sv[SZ], sv2[SZ];
vector<ll> wn[SZ];
bitset<SZ> cur;

int main()
{
	fastInp;

	cin >> n;

	for (int i = 1; i <= n + 1; i++) {
		sv[i - 1][i] = 1;
		sv2[i][i - 1] = 1;
	}
	for (int i = 1; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == '1') {
				grid[i + 1][j + 1] = 1;
			}
			else {
				grid[j + 1][i + 1] = 1;
			}
		}
	}

	for (int i = 0; i <= n + 3; i++) {
		cur = 0;
		for (int j = 0; j < i; j++) cur[j] = 1;
		msk[i] = cur;
	}
	for (int i = 2; i <= n + 1; i++) {
		for (int j = 0; j <= n + 1; j++) {
			ll lft = j, rt = j + i;
			if (lft == 2 && rt == 4) {
				cout << "";
			}
			if (rt <= n + 1) {
				if ((((sv[lft] & grid[lft] & sv2[rt]) >> lft) & msk[i + 1]) != 0 || (((sv2[rt] & grid[rt] & sv[lft]) >> lft) & msk[i + 1]) != 0) {
					sv[lft][rt] = 1;
					sv2[rt][lft] = 1;
				}
			}
		}
	}

	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (sv[0][i] && sv[i][n + 1]) {
			ans++;
		}
	}

	cout << ans;

	return 0;
}