package com.codegym.task.task07.task0718;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
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 i = 1; i < list.size();){
if (list.get(i).length() <= list.get(i - 1).length()) {
System.out.println (i);
break;
} else {
i++;
}
}
}
}
package com.codegym.task.task07.task0718;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
/*
1. Declare a string list variable and immediately initialize it.
2. Read 10 lines from the keyboard and add them to the list.
3. If the list is ordered by increasing string length, then you don't need to display anything.
4. If the list is not ordered by increasing string length, then display the index of the first element that violates this order.
*/
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 i = 1; i < list.size();){
if (list.get(i).length() <= list.get(i - 1).length()) {
System.out.println (i - 1);
break;
} else {
i++;
}
}
}
}