시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 2823 906 712 32.437%

문제

어떤 글을 살짝 오른쪽으로 살짝 회전시켜 놓고, 첫째 줄의 첫 번째 문자 위에 공을 하나 올려놓는다. 공은 중력에 의해서 아래로 굴러 떨어지게 된다. 공은 글자 사이에 빠지지 않고 움직일 수 있고, 공백을 만난 경우에는 아래로 떨어진다. 첫 번째 열의 번호가 1번일 때, 공이 몇 번째 열에서 바닥으로 떨어지게 되는지 구하는 프로그램을 작성하시오. 아래 예제에서 공은 8번 열에서 바닥으로 떨어진다.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다.각 테스트 케이스의 첫째 줄에는 줄의 수 n (1 ≤ n ≤ 1000)이 주어진다. 다음 n개 줄에는 각 줄의 글이 주어진다. 글은 인쇄할 수 있는 아스키 문자와 공백으로만 이루어져 있다. 인쇄할 수 없는 문자나 탭은 입력으로 주어지지 않는다. 각 줄의 길이는 1보다 크거나 같고, 100보다 작거나 같다.

입력의 마지막 줄에는 0이 하나 주어진다.

출력

각 테스트 케이스 마다, 공이 몇 번째 열에서 바닥으로 떨어지는지 출력한다.

예제 입력 1

4
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
3
Supercalifragilisticexpialidocious! Can you handle
short
lines?
0

예제 출력 1

8
36
W3sicHJvYmxlbV9pZCI6Ijk0OTQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIzNzBcdWFkNmNcdWI5NzRcdWI5NzQiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzViNFx1YjVhNCBcdWFlMDBcdWM3NDQgXHVjMGI0XHVjOWRkIFx1YzYyNFx1Yjk3OFx1Y2FiZFx1YzczY1x1Yjg1YyBcdWMwYjRcdWM5ZGQgXHVkNjhjXHVjODA0XHVjMmRjXHVjZjFjIFx1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