#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define SIZE 2010
bool A[SIZE][SIZE];
bitset<SIZE> l[SIZE];
bitset<SIZE> r[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 = N - 1; i >= 0; --i) {
    l[i][i] = true;
    r[i][i + 1] = true;
    bitset<SIZE> X;
    for (int j = i + 1; j < N; ++j) {
      if ((l[j] & r[i]).any()) {
        if (A[i][j])
          r[i] |= r[j];
        else {
          l[j][i] = true;
          X[j] = true;
        }
      }
      if ((X & l[j]).any()) {
        l[j][i] = true;
        X[j] = true;
      }
    }
  }

  ll ret=0;
  for(int i=0;i<N;i++)
  {
    if(l[i][0]&&r[i][N])
    {
      ret++;
    }
  }
  cout << ret << endl;
}
