#Lutece0892. Exponential Towers

Exponential Towers

Migrated from Lutece 892 Exponential Towers

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

The number 729729 can be written as a power in several ways: 363^6, 939^3 and 27227^2. It can be written as 7291729^1, of course, but that does not count as a power. We want to go some steps further. To do so, it is convenient to use ^ for exponentiation, so we define a^b=aba\verb|^|b = a^b. The number 256256 then can be also written as 2^2^3, or as 4^2^2. Recall that ^ is right associative, so 2^2^3 means 2^(2^3).

We define a tower of powers of height kk to be an expression of the form $a_1\verb|^|a_2\verb|^|a_3\verb|^|\ldots \verb|^| a_k$, with k>1k > 1, and integers ai>1a_i > 1.

Given a tower of powers of height 33, representing some integer nn, how many towers of powers of height at least 33 represent nn?

Input

The input file contains several test cases, each on a separate line. Each test case has the form a^b^ca\verb|^|b\verb|^|c, where aa, bb and cc are integers, 1<a,b,c95851 < a, b, c \leq 9585.

Output

For each test case, print the number of ways the number n=a^b^cn = a\verb|^|b\verb|^|c can be represented as a tower of powers of height at least three.

The magic number 95859585 is carefully chosen such that the output is always less than 2632^{63}.

Samples

4^2^2
8^12^2
8192^8192^8192
2^900^576
2
10
1258112
342025379

Resources

Northwestern European Regional Contest 2013