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

typedef long long LL;

const int N=2000;

int n;
char s[N+9];
bitset<N+9>a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=2;i<=n;++i){
	scanf("%s",s+1);
	for (int j=1;j<i;++j) a[j][i]=(a[i][j]=s[j]-'0')^1;
  }
}

bitset<N+9>dp[2][N+9];

void Get_dp(){
  for (int i=1;i<=n;++i) dp[0][i][i]=dp[1][i][i]=1;
  for (int len=2;len<=n;++len)
	for (int l=1;l+len-1<=n;++l){
	  int r=l+len-1;
	  if ((a[l]&dp[1][l+1]&dp[0][r]).count()) dp[0][r][l]=1;
	  if ((a[r]&dp[1][l]&dp[0][r-1]).count()) dp[1][l][r]=1;
	}
}

void work(){
  Get_dp();
}

void outo(){
  printf("%d\n",(dp[0][n]&dp[1][1]).count());
}

int main(){
  into();
  work();
  outo();
  return 0;
}