#C3982. Count Anagram Groups

    ID: 47469 Type: Default 1000ms 256MiB

Count Anagram Groups

Count Anagram Groups

Given a list of words, your task is to determine the number of distinct groups of anagrams. Two words are considered anagrams if one can be rearranged to form the other. For example, the words listen and silent are anagrams since they contain the same letters in a different order.

Mathematically, if we denote a word as a sequence of characters, and \( f(word) \) represents the sorted sequence of its letters in increasing order, then two words \( w_1 \) and \( w_2 \) belong to the same anagram group if and only if \( f(w_1)=f(w_2) \). Your task is to compute the number of unique \( f(word) \) values among all given words.

inputFormat

The input is given via stdin and is formatted as follows:

n
word1
word2
... 
wordn

Where n is a positive integer representing the number of words, followed by n lines each containing a single word.

outputFormat

Output a single integer to stdout representing the number of distinct anagram groups.

## sample
6
listen
silent
enlist
hello
world
drolw
3