Codeforces Round 491 (Div. 2) |
---|
Finished |
This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all.
In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number $$$n$$$.
In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could "see" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too.
Given $$$n$$$, determine the total number of possible bus number variants.
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^{18}$$$) — the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with $$$0$$$.
Output a single integer — the amount of possible variants of the real bus number.
97
2
2028
13
In the first sample, only variants $$$97$$$ and $$$79$$$ are possible.
In the second sample, the variants (in the increasing order) are the following: $$$208$$$, $$$280$$$, $$$802$$$, $$$820$$$, $$$2028$$$, $$$2082$$$, $$$2208$$$, $$$2280$$$, $$$2802$$$, $$$2820$$$, $$$8022$$$, $$$8202$$$, $$$8220$$$.
Name |
---|