#K90697. Unique Anagram Count

    ID: 37810 Type: Default 1000ms 256MiB

Unique Anagram Count

Unique Anagram Count

In this problem, you are given a list of strings. An anagram is a word formed by rearranging the letters of another word. Two strings are considered anagrams if their characters, when sorted, are identical. Your task is to count the number of unique anagram groups in the list.

More formally, for a given list of strings \(S = [s_1, s_2, \dots, s_n]\), two strings \(s_i\) and \(s_j\) belong to the same group if \(\text{sorted}(s_i) = \text{sorted}(s_j)\). Output the number of distinct groups.

For example, the strings listen, silent, and enlist form one unique group.

inputFormat

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

  1. The first line contains an integer \(n\) representing the number of strings.
  2. The next \(n\) lines each contain a single string.

It is guaranteed that \(1 \leq n \leq 10^5\) and each string has a reasonable length.

outputFormat

Output a single integer to standard output (stdout) representing the number of unique anagram groups among the provided strings.

## sample
3
listen
silent
enlist
1