#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    bitset<2020> A[2020];
    for (int n = 1; n < N; ++n) {
        string S;
        cin >> S;
        for (int m = 0; m < n; ++m) {
            A[n][m] = S[m]-'0';
            A[m][n] = 1-A[n][m];
        }
    }
    
    bitset<2020> DP[2020];
    for (int n = 0; n < N; ++n) {
        DP[n][n] = 1;
    }
    for (int d = 1; d <= N-1; ++d) {
        for (int i = 0; i+d < N; ++i) {
            int j = i+d;
            DP[j][i] = (A[i] & DP[i+1] & DP[j]).any();
            DP[i][j] = (A[j] & DP[i] & DP[j-1]).any();
        }
    }
    int Res = 0;
    for (int n = 0; n < N; ++n) {
        if (DP[0][n] & DP[N-1][n]) ++Res;
    }
    cout << Res << endl;

    return 0;
}
