#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define SIZE 2010
// 誰に勝てるか（入力）
bitset<SIZE> A[SIZE];
// left[i]=iが左端で優勝できる可能性があるか
bitset<SIZE> left_[SIZE];
// right[i]=iが右端で優勝できる可能性があるか
bitset<SIZE> right_[SIZE];


int main() {
  ll N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < i; ++j) {
      char a;
      cin >> a;
      A[i][j] = a == '1';
      A[j][i] = !A[i][j];
    }
  }

  for (int i = 0; i < N; ++i) {
    left_[i][i] = 1;
    right_[i][i] = 1;
  }
  
  // [i,j]の範囲を徐々に広げながらdp
  for (int len = 2; len <= N; ++len) {
    for (int l = 0; l+len <= N; ++l) {
      int r = l+len -1;
      if((left_[l+1] & right_[r] & A[l]).any())
        right_[r][l] = 1;
      if((left_[l] & right_[r-1] & A[r]).any())
        left_[l][r] = 1;
    }
  }

  cout << (int)((left_[0]&right_[N-1]).count()) << endl;
}
