ArrayList<String> list = new ArrayList<String>();

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        for (int i=0; i < 10; i++) {
            list.add(reader.readLine());
        }

        int last;
        int current;

        for (int j =0; j < list.size(); j++) {
            current = list.get(j).length();
            if (j == 0) {
                last = 0;
            } else {
                last = list.get(j-1).length();
            }

            if (current < last) {
                System.out.println(list.indexOf(list.get(j)));
                break;
            }
        }
This code passed test in task. But there is small bug if you use same string. For example (i will use only 5 even it is asked for 10): 1 12 123 1 12345 You will get answer index number 0 because index 0 and index 3 have the same value. How to avoid this ? Edit: In Level 7 Lesson 10 there is an article which explains use of indexOf() - and it is working as it is supposed to. But still is there other solution to this problem :)