public class Solution { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> list = new ArrayList<>(); while (true) { String s = reader.readLine(); if (s.isEmpty()) break; list.add(s); } for (int a = 0; a < list.size() - 1;) { if (list.get(a).length() < list.get(a + 1).length()) a++; else { System.out.println(a + 1); break; } } } }