#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n; std::cin >> n;
  constexpr size_t max = 2002;
  auto a = std::vector<std::bitset<max>>(n + 2);
  auto insert = [&] (size_t i, size_t j, bool k) {
    a[i][j] = k;
    a[j][i] = !k;
  };
  for (size_t i = 1; i <= n; i++) {
    insert(i, 0, true);
    insert(i, n + 1, true);
  }
  for (size_t i = 2; i <= n; i++) {
    for (size_t j = 1; j < i; j++) {
      char x; std::cin >> x;
      insert(i, j, x == '1');
    }
  }
  auto dp = std::vector<std::bitset<max>>(n + 2);
  for (size_t i = 0; i <= n; i++) dp[i][i + 1] = dp[i + 1][i] = true;
  for (size_t d = 2; d <= n + 1; d++) {
    for (size_t i = 0, j = d; j <= n + 1; i++, j++) {
      dp[j][i] = dp[i][j] = (dp[i] & dp[j] & (a[i] | a[j])).any();
    }
  }
  int ret = 0;
  for (size_t i = 1; i <= n; i++) {
    if (dp[0][i] & dp[i][n + 1]) ret++;
  }
  std::cout << ret << std::endl;
  return 0;
}
