spoj#DUGDUG. DUGDUG
DUGDUG
Dug Dug is a sweet and cute girl who just loves to eat sweet and choclates but only those which I used to gift her. One day I just said that "DUG DUG you are sweet and also like sweet". I will give you as many sweets as you want but you have to tell me the number of ways you can exchange the words in the sentence such that the sentence is not changed. Note that you can exchange one or more pair of words in the sentence simultaneously but all those pairs should be of different words. Dug Dug was confused. She got angry and said if you want to give the sweet then give otherwise go from here. I said "I i will , i i i will give". She got the choclates but you will not get it easily.
Your task is to find out the number of ways words in a sentence can be exchanged without changing the sentence. Note - one or more pair of words in the sentence can be exchanged simultaneously but all those pairs should be of different words.
Input
Input will consists of several lines each containing a sentence consisting of not more than 5000 characters.
Output
For each line of input out a single integer denoting the number of ways in which words in a sentence can be exchanged without changing the sentence.
Example
Input: DUG DUG you are sweet and also like sweet
I i will , i i i will give
Ok done you will get what you want
Done !!!!!!!!
Output: 3
13
1
0
Explaination:
For the first sentence "DUG DUG you are sweet and also like sweet" there are three ways -
1) You can change the first "DUG" with second "DUG"
2) You can change the first "sweet" with second "sweet"
3) You can change the first "DUG" with second "DUG" and first "sweet" with second "sweet".