The football World Cup is held every four years, and hosting it is an honor worth a fierce campaign. The host is chosen by a vote.
The candidate countries are C1,C2,…,Cn. Two of the countries still in the race are picked and put to a head to head vote, and the loser drops out. This repeats until one country is left, and that country becomes the host.
A poll has already been run. For any two countries we know which one wins their duel, and there are no ties. The same pair always ends the same way, no matter when the two meet.
Given the poll, count the countries that still have a chance of becoming the host. A country has a chance when some order of picking pairs leaves it as the last one standing.
The input holds several test cases.
The first line of each test case contains the number of candidate countries n (0<n≤1000). The next n lines give the poll. The i-th of them is a string of n−i characters, each 0 or 1, whose j-th character is 1 if Ci beats Ci+j and 0 if Ci+j beats Ci. The n-th line of every test case is therefore empty.
The last line of the input contains a single 0.
For each test case, print on one line the number of countries that can become the host according to the poll.