#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

using bs=bitset<2000>;

int N;
// r l            l r
bs leftwin[2000],rightwin[2000];
bs G[2000];
signed main(){
    cin>>N;
    for(int i=1;i<N;i++){
        string s;cin>>s;
        for(int j=0;j<i;j++){
            if(s[j]=='1')G[i][j]=1;
            else G[j][i]=1;
        }
    }


    for(int i=0;i<N;i++)leftwin[i][i]=rightwin[i][i]=1;
    for(int len=2;len<=N;len++){
        for(int i=0;i+len<=N;i++){
            int j=i+len-1;

            if((rightwin[i+1]&leftwin[j]&G[i]).count())leftwin[j][i]=1;
            if((rightwin[i]&leftwin[j-1]&G[j]).count())rightwin[i][j]=1;
        }
    }

    cout<<(rightwin[0]&leftwin[N-1]).count()<<endl;
    return 0;
}