#include <iostream>
#include <vector>
#include <string>
#include <time.h>
using namespace std;

int main()
{
    int N;
    //cin>>N;
    scanf("%d", &N);
    //vector<vector<bool>> A(N, vector<bool>(N));
    static bool A[2048][2048];
    for (int i=1; i<N; i++)
    {
        //string t;
        //cin>>t;
        for (int j=0; j<i; j++)
        {
            char c;
            scanf(" %c", &c);
            A[i][j] = c!='0';
            A[j][i] = !A[i][j];
        }
    }

    //vector<vector<bool>> L(N, vector<bool>(N));
    //vector<vector<bool>> R(N, vector<bool>(N));
    static bool L[2048][2048];
    static bool R[2048][2048];
    for (int i=0; i<N; i++)
        L[i][i] = R[i][i] = true;

    /*
    for (int d=1; d<N; d++)
        for (int i=0; i<N; i++)
        {
            if (i+d<N)
                for (int j=i+1; j<N; j++)
                    if (A[i][j] && L[j][i+d] && R[j][i+1])
                        L[i][i+d] = true;

            if (0<=i-d)
                for (int j=0; j<i; j++)
                    if (A[i][j] && L[j][i-1] && R[j][i-d])
                        R[i][i-d] = true;
        }

    int ans = 0;
    for (int i=0; i<N; i++)
        if (L[i][N-1] && R[i][0])
            ans += 1;
    */


    for (int d=1; d<N; d++)
        for (int i=0; i<N; i++)
        {
            if (i+d<N)
            {
                bool b = false;
                for (int j=i+1; j<=i+d; j++)
                    b |= A[i][j] & L[i+d][j] & R[i+1][j];
                L[i+d][i] = b;
            }

            if (0<=i-d)
            {
                bool b = false;
                for (int j=i-d; j<i; j++)
                    b |= A[i][j] & L[i-1][j] & R[i-d][j];
                R[i-d][i] = b;
            }
        }

    int ans = 0;
    for (int i=0; i<N; i++)
        if (L[N-1][i] && R[0][i])
            ans += 1;

    cout<<ans<<endl;

    cerr<<(double)clock()/CLOCKS_PER_SEC<<endl;
}
