#K50792. Counting Unique Groups

    ID: 28943 Type: Default 1000ms 256MiB

Counting Unique Groups

Counting Unique Groups

In this problem, you are given a collection of strings. Two strings belong to the same group if they consist of the same set of characters, regardless of order or frequency. For example, the strings abc and bac are in the same group, while abc and adb are in different groups because the set of characters differs. Your task is to compute the number of unique groups among the given strings.

More formally, for a string (s), let (G(s)) be the set of unique characters in (s). Two strings (s_1) and (s_2) are in the same group if (G(s_1) = G(s_2)). You need to output the number of distinct values of (G(s)) among all the strings.

inputFormat

The input is given via stdin and has the following format:

  • The first line contains a single integer (n) (1 (\leq n \leq 10^5)), the number of strings.
  • The following (n) lines each contain a non-empty string consisting of lowercase English letters.

outputFormat

Output a single integer via stdout representing the number of unique groups of strings.## sample

4
abc
bac
adb
dbaa
2

</p>