IATI | alpha

This was the problem page during the contest. Access the current page here.
Time limit: 2s
Memory limit: 150MB
Input:
Output:

There are 26 students in Elly's English class. Since this number is exactly the same as the number of letters in the English alphabet, the kids play the following game. In increasing order of their number (in Bulgaria each student in a class has a unique number) each of them says one letter from his/her name. For example, ELLY can say one of the letters 'E', 'L', or 'Y'; KRISS can say 'K', 'R', 'I', or 'S'; and STAN can say 'S', 'T', 'A', or 'N'. Please note that if there are repeating letters in someone's name (which is the case for ELLY and KRISS) it doesn't matter which one they choose - the letter the other kids hear is the same.

Their teacher wants each of the letters in the alphabet to be said exactly once, thus getting a permutation of the letters of the alphabet. Now Elly wonders how many different permutations they can form.

Input

On the standard input, will be given 26 strings Si containing only uppercase letters of the English alphabet - the name of each of the children in the order they are in the class. Each name is no more than five characters long. It is possible that some of the people have the same name.

Output

On a single line of the standard output print one integer - the number of different permutations of the English alphabet that can be formed if we take one character from the first string, followed by one character from the second string and so on. It is guaranteed that for every input the answer is less than 101810^{18}.

Constraints

  • 1Si51 ≤ |S_i| ≤ 5
  • In tests worth around 20% of the points for the task: 1Si31 ≤ |S_i| ≤ 3
  • In tests worth around 50% of the points for the task: 1Si41 ≤ |S_i| ≤ 4

Example

stdin

ELLY KRISS STAN WU ALEX ZOE POOH KATE VILI MAXIM QT G ZAEK BOBI TEO YOYO DEQN FIL CECO DAWG JORO MONI SASHO DUDA VESKO POOH

stdout

1592

stdin

ESPR SHUM ENNN BULG ARIA YOU HAVE TO SOLVE HARD TASKS WHO WILL WIN THIS TIME CDFMQ CEFHJ GIOTV JOSUW CRVWX KMSYZ HQRUZ DGWXY BMRTU MUXYZ

stdout

48627

Explanation

Some of the possible permutations in the first sample are ERAULOHKIXQGZBTYNFCWJMSDVP, LRNWXEHAVITGZBOYQFCDJMSUKP and YRTWXZPKLMQGABEONFCDJISUVH.

Contest info

Virtual contest

Start time: 1713245400000

Total duration: 5h0m0s

Status: Ended

Individual duration: 4h59m59s

Log in or sign up to be able to send submissions!