Anagram Analyser
In the local newspaper, there is a section on unscrambling anagrams. You want to always solve it most efficiently, so you try to make a program to do it for you. The newspaper presents a whole bunch of words, and two words are anagrams if they contain the same letters in the same amounts, but perhaps different orders. You need to find out how many different groups of anagrams there are.
Input
The first line contains an integer , which represents the number of strings there are. The next
lines each contain a string, with each string only containing lowercase alphabetical characters and being between
and
characters long.
Output
Output the number of distinct anagram groups as an integer.
Example
Input 1
6
slow
rat
lows
tar
art
this
Output 1
3
The tree anagram groups are (slow, lows)
, (rat, tar, art)
, and (this)
.
Comments