import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Iterator; 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 Balloon2 { 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] = ""; ArrayList a = new ArrayList<>(); BigInteger line = new BigInteger(scanner.nextLine()); while (true) { if (line.equals(new BigInteger("0"))) { break; } a.add(line.mod(new BigInteger("10"))); line = line.divide(new BigInteger("10")); } a.sort(new Comparator() { @Override public int compare(BigInteger o1, BigInteger o2) { return o1.compareTo(o2); } }); for (int j = 0; j < a.size() - 1; j++) { if (a.get(j).equals(a.get(j + 1))) { a.remove(j); j--; } } for (int j = 0; j < a.size(); j++) { input[i] += a.get(j); } } ArrayList fakju = new ArrayList<>(); for (int i = 0; i < input.length; i++) { fakju.add(input[i]); } fakju.sort(new Comparator() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }); for (int j = 0; j < fakju.size() - 1; j++) { if (fakju.get(j).equals(fakju.get(j + 1))) { fakju.remove(j); j--; } } System.out.println("" + fakju.size()); } } }