import java.util.ArrayList; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author mahansky */ public class Balloon { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextLine()) { int rowCount = Integer.parseInt(scanner.nextLine()); String[] input = new String[rowCount]; for (int i = 0; i < rowCount; i++) { input[i] = scanner.nextLine(); } ArrayList categories = new ArrayList<>(); categories.add(input[0]); for (int i = 1; i < rowCount; i++) { for (int j = 0; j < categories.size(); j++) { if (!compare(input[i], categories.get(j)) || !compare(categories.get(j), input[i])) { boolean add = true; for (int k = 0; k < categories.size(); k++) { if (compare(input[i], categories.get(k)) && compare(categories.get(k), input[i])) { add = false; } } if (add) { categories.add(input[i]); } } } } System.out.println(categories.size() + ""); } } public static boolean compare(String a, String b) { for (int i = 0; i < a.length(); i++) { if (!b.contains("" + a.charAt(i))) { return false; } } return true; } }