publicclassLoopWord{ publicstaticvoidmain(String[] args){ Scanner scanner = new Scanner(System.in); while (scanner.hasNext()){ int n = scanner.nextInt(); List<String> list = new LinkedList<>(); W : for (int i = 0; i < n; ++i){ String s = scanner.next(); for(String t : list) { if(t.contains(s) && t.length() == s.length() * 2) continue W; } list.add(s + s); } System.out.println(list.size()); } } }