import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;

class Torstein_n2logn {

    static class Node implements Comparable<Node> {
        int id;
        int score;

        Node(int id, int score) {
            this.id = id;
            this.score = score;
        }

        @Override
        public int compareTo(Node that) {
            return this.score - that.score;
        }
    }

    public static void main(String[] args) {
        Kattio io = new Kattio(System.in, System.out);

        int n = io.getInt();
        int[][] graph = new int[n][n];
        for (int i = 1; i < n; i++) {
            String line = io.getWord();
            for (int j = 0; j < i; j++) {
                if (line.charAt(j) == '1') graph[i][j] = 1;
                else graph[j][i] = 1;
            }
        }

        boolean[] done = new boolean[n];
        int[] costs = new int[n];
        PriorityQueue<Node> pq = new PriorityQueue<>();

        for (int i = 0; i < n; i++) {
            int cost = 0;
            for (int j = 0; j < n; j++) {
                cost += graph[i][j];
            }
            costs[i] = cost;
            pq.add(new Node(i, cost));
        }

        int runscore = 0;
        int worstscore = 0;
        while (!pq.isEmpty()) {
            Node node = pq.poll();
            if (done[node.id]) { continue; }

            done[node.id] = true;
            runscore += node.score;
            worstscore = worstscore > runscore ? worstscore : runscore;
            for (int i = 0; i < n; i++) {
                if (!done[i]) {
                    if (graph[i][node.id] > 0) {
                        //Score for i decrease, since moving it over will mitigate one loser beating a winner
                        costs[i] -= 1;
                        pq.add(new Node(i, costs[i]));
                    }
                    else {
                        // Score for i decrease, since there will be one less loser beating i if i is moved over.
                        costs[i] -= 1;
                        pq.add(new Node(i, costs[i]));
                    }
                }
            }
        }

        io.println(worstscore);
        io.flush();
        io.close();
    }
}

class Kattio extends PrintWriter {
    public Kattio(InputStream i) {
        super(new BufferedOutputStream(System.out));
        r = new BufferedReader(new InputStreamReader(i));
    }
    public Kattio(InputStream i, OutputStream o) {
        super(new BufferedOutputStream(o));
        r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasMoreTokens() {
        return peekToken() != null;
    }

    public int getInt() {
        return Integer.parseInt(nextToken());
    }

    public double getDouble() {
        return Double.parseDouble(nextToken());
    }

    public long getLong() {
        return Long.parseLong(nextToken());
    }

    public String getWord() {
        return nextToken();
    }

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
        if (token == null)
            try {
                while (st == null || !st.hasMoreTokens()) {
                    line = r.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
                token = st.nextToken();
            } catch (IOException e) { }
        return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }
}
