textroll/TextRoll_artur.java

  1 import java.io.BufferedReader;
  2 import java.io.InputStreamReader;
  3 
  4 public class TextRoll_artur {
  5   public static void main(String[] args) throws Exception {
  6     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  7 
  8     for (int n = Integer.parseInt(in.readLine()); n != 0; n = Integer.parseInt(in.readLine())) {
  9       int pos = 0;
 10       for (int i = 0; i < n; i++) {
 11         String s = in.readLine();
 12         int j = s.indexOf(' ', pos);
 13         pos = j == -1 ? Math.max(pos, s.length()) : j;
 14       }
 15       System.out.println(pos + 1);
 16     }
 17   }
 18 }