#K71852. Count Anagram Groups

    ID: 33623 Type: Default 1000ms 256MiB

Count Anagram Groups

Count Anagram Groups

You are given a list of words. Two words are considered anagrams if one can be rearranged to form the other. For example, the words "listen", "silent", and "enlist" are mutually anagrams.

Your task is to count the number of unique anagram groups among the given words. Formally, for each word, define its sorted representation as \(s = \text{sort}(word)\). Two words belong to the same anagram group if their sorted representations are identical. Compute and output the number of distinct anagram groups in the list.

inputFormat

The input is read from standard input and has the following format:

n
word1
word2
... 
wordn

Here, n is a non-negative integer representing the number of words, followed by n lines each containing one word comprised of lowercase letters.

outputFormat

Output a single integer to standard output representing the number of unique anagram groups.

## sample
6
listen
silent
enlist
hello
olleh
world
3