You are given two strings - S and one of its permutations - P. You need to find the number of the string P among all permutations of the string S, sorted in descending lexicographic order.
Input:
The input is two strings - S and P (1 =< |S| <= 9). The strings contain only lowercase Latin letters.
Output:
Print a single number - the number of the permutation P.
Enter |
Output |
abcd dcba |
1 |
abc abc |
6 |
(c) Ahmad Ibrahim