#include <bits/stdc++.h>
using namespace std;

const int DEBUG = 1;
const int mxn = 2e3;
int n;
bitset<mxn> a[mxn]; 
bitset<mxn> dp[mxn],dpr[mxn]; 

#define f(i,a,b) for (int i = a; i < b; i++)

// NOT MINE LOL ... See Um_nik's first

int main() {

#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	cin>>n;

	f(i,1,n) {
		string s;
		cin>>s;
		f(j,0,i) a[i][j] = s[j] == '1', a[j][i] = !a[i][j];
	}	
	f(i,0,n) dp[i][i] = dpr[i][i] = 1;

	f(len,1,n) f(l,0,n-len) {
		int r = l+len;	
		if ((a[l]&dpr[l+1]&dp[r]).any())
			dp[r][l]=1;
		if ((a[r]&dpr[l]&dp[r-1]).any())
			dpr[l][r]=1;
	} 

	cout << (dpr[0]&dp[n-1]).count() << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif


	return 0;
}
