Untitled
Never
import java.util.Scanner; public class Main { public static boolean isRotation(String str1, String str2) { if (str1.length() != str2.length() || str1.isEmpty()) { return false; } String concatenated = str1 + str1; return concatenated.contains(str2); } public static int findRotationLevel(String str1, String str2) { if (!isRotation(str1, str2)) { return -1; } for (int i = 1; i <= str1.length(); i++) { if (isRotation(str1.substring(i) + str1.substring(0, i), str2)) { return i+1; } } return -1; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] str = sc.nextLine().split(" "); int rotationLevel = findRotationLevel(str[0], str[1]); System.out.println(rotationLevel); } }