// https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_f
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

// Input macros.
// Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! read_line {
    ($t:tt) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s.trim_right().parse::<$t>().unwrap()
        }
    }
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}


// ===


#[derive(Clone, Debug)]
struct BitVector {
    n: usize,
    size: usize,
    data: Vec<u64>
}

impl BitVector {
    fn new(n: usize) -> Self {
        let size = (n+63)/64;
        BitVector {
            n: n,
            size: size,
            data: vec![0; size]
        }
    }

    fn get(&self, i: usize) -> bool {
        self.data[i/64]>>(i%64) & 1 != 0
    }

    fn set(&mut self, i: usize) {
        self.data[i/64] |= 1<<(i%64);
    }

    fn count(&self) -> usize {
        let mut cnt = 0;
        for i in 0..self.size {
            cnt += self.data[i].count_ones();
        }
        cnt as usize
    }
}

impl<'a> std::ops::Shl<usize> for &'a BitVector {
    type Output = BitVector;

    fn shl(self, amount: usize) -> Self::Output {
        let mut new_vector = BitVector::new(self.n);

        let diff = amount / 64;
        let diff_mod = amount % 64;
        if diff_mod == 0 {
            for i in 0..self.size-diff {
                new_vector.data[i+diff] = self.data[i];
            }
        } else {
            let lower_mask = (1<<(64-diff_mod))-1;
            let upper_mask = ((1<<diff_mod)-1)<<(64-diff_mod);
            for i in 0..self.size-diff {
                new_vector.data[i+diff] |= (self.data[i] & lower_mask)<<diff_mod;
                if i+diff+1 < self.size {
                    new_vector.data[i+diff+1] |= (self.data[i] & upper_mask)>>(64-diff_mod);
                }
            }
        }
        new_vector
    }
}


impl<'a> std::ops::Shr<usize> for &'a BitVector {
    type Output = BitVector;

    fn shr(self, amount: usize) -> Self::Output {
        let mut new_vector = BitVector::new(self.n);

        let diff = amount / 64;
        let diff_mod = amount % 64;
        if diff_mod == 0 {
            for i in diff..self.size {
                new_vector.data[i-diff] = self.data[i];
            }
        } else {
            let lower_mask = (1<<diff_mod)-1;
            let upper_mask = ((1<<(64-diff_mod))-1)<<diff_mod;
            for i in diff..self.size {
                new_vector.data[i-diff] |= (self.data[i] & upper_mask)>>diff_mod;
                if i > diff {
                    new_vector.data[i-diff-1] |= (self.data[i] & lower_mask)<<(64-diff_mod);
                }
            }
        }
        new_vector
    }
}

impl<'a> std::ops::BitAnd for &'a BitVector {
    type Output = BitVector;

    fn bitand(self, other: Self) -> Self::Output {
        let mut output = BitVector::new(self.n);
        for i in 0..self.size {
            output.data[i] = self.data[i] & other.data[i];
        }
        output
    }
}

impl std::ops::BitAndAssign for BitVector {
    fn bitand_assign(&mut self, rhs: Self) {
        for i in 0..min(self.size, rhs.size) {
            self.data[i] &= rhs.data[i];
        }
    }
}

impl<'a> std::ops::BitOr for &'a BitVector {
    type Output = BitVector;

    fn bitor(self, other: Self) -> Self::Output {
        let mut output = BitVector::new(self.n);
        for i in 0..self.size {
            output.data[i] = self.data[i] | other.data[i];
        }
        output
    }
}

impl std::ops::BitOrAssign for BitVector {
    fn bitor_assign(&mut self, rhs: Self) {
        for i in 0..min(self.size, rhs.size) {
            self.data[i] |= rhs.data[i];
        }
    }
}

impl std::ops::BitXorAssign for BitVector {
    fn bitxor_assign(&mut self, rhs: Self) {
        for i in 0..min(self.size, rhs.size) {
            self.data[i] ^= rhs.data[i];
        }
    }
}

//===

fn main() {
    input! {
        n: usize,
        table: [chars; n-1]
    };

    // 1 to n, 0 and n+1 are sentinels
    let mut wintable = vec![BitVector::new(2048); n+2];
    for i in 2..n+1 {
        for j in 1..i {
            if table[i-2][j-1] == '1' {
                // i wins j
                wintable[i].set(j);
            } else {
                wintable[j].set(i);
            }
        }
    }

    let mut dp_left = vec![BitVector::new(2048); n+2];
    let mut dp_right = vec![BitVector::new(2048); n+2];

    let mut dp_left_rev = vec![BitVector::new(2048); n+2];
    let mut dp_right_rev = vec![BitVector::new(2048); n+2];

    for i in 1..n+1 {
        dp_left[i].set(i);
        dp_right[i].set(i);
        dp_left_rev[i].set(i);
        dp_right_rev[i].set(i);
    }
    for l in 1..n {
        for i in 1..n+1 {
            if i > l {
                let lj = i-l;
                let mut ok = false;
                ok |= (&dp_left[i] & &dp_left_rev[lj]).count() >= 1;
                ok |= (&(&(&dp_left[i]>>1) & &dp_left_rev[lj]) & &wintable[i]).count() >= 1;
                ok |= wintable[i].get(lj) && (&dp_left[i] & &(&dp_right[lj]<<1)).count() >= 1;
                if ok {
                    dp_left[i].set(lj);
                    dp_left_rev[lj].set(i);
                }
            }
            if i+l <= n {
                let rj = i+l;
                let mut ok = false;
                ok |= (&dp_right[i] & &dp_right_rev[rj]).count() >= 1;
                ok |= (&(&(&dp_right[i]<<1) & &dp_right_rev[rj]) & &wintable[i]).count() >= 1;
                ok |= wintable[i].get(rj) && (&dp_right[i] & &(&dp_left[rj]>>1)).count() >= 1;
                if ok {
                    dp_right[i].set(rj);
                    dp_right_rev[rj].set(i);
                }
            }
        }
    }


    let mut count = 0;
    for i in 1..n+1 {
        if dp_left[i].get(1) && dp_right[i].get(n) {
            count += 1;
            // debug!(i);
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 18812