#C11185. Unique Book Types

    ID: 40473 Type: Default 1000ms 256MiB

Unique Book Types

Unique Book Types

You are given a collection of books where each book is represented as a string. Two books are considered of the same type if their character frequency distributions are identical. In other words, let \( f(b) \) be the frequency count of all characters in book \( b \). Two books \( b_1 \) and \( b_2 \) are of the same type if \( f(b_1) = f(b_2) \).

Your task is to determine the number of unique book types.

Note: For each book, its signature can be defined using the formula:

[ \text{signature}(book) = \mathrm{sorted}({(c, \text{count}(c)) : c \in book}) ]

This means that the order of characters does not matter, only their frequencies.

inputFormat

The input is given from standard input (stdin) and has the following format:

The first line contains an integer ( n ) which is the number of books. Each of the next ( n ) lines contains a non-empty string representing a book.

outputFormat

Output to standard output (stdout) a single integer representing the number of unique book types.## sample

5
aabbcc
bbaacc
abc
bac
xyz
3