eolymp
bolt
Try our new interface for solving problems
Problems

Fermat

Fermat

\textit{...everything is composed in the distant Middle Ages - and modern authors only voruetsya. A medieval writers, in turn, these thoughts have pokrali antique, and if they have something new flashed - this means that sources are not preserved and not come down to us.} J. Huberman Probably no one person in the world who would not have heard of Fermat's Last Theorem. It has a unique history, which has perhaps not a theorem in the world, fought over it the world's best minds for \textbf{350} years until it was proved by Andrew Wiles American mathematician. Statement of the theorem is quite simple: for every integer \textbf{k} > \textbf{2}, the equation \textbf{x^k + y^k = z^k} has no positive solutions \textbf{a}, \textbf{b} and \textbf{c}. To be precise, Fermat wrote in the margins of the book of Diophantus 'Arithmetic': "\textit{You can not decompose a cube into two cubes, or square-square (ie, the fourth power of the number) of two square-square, nor do any degree above the square and up to infinity can not be decomposed into two levels with the same exponent. I discovered this a truly wonderful proof, but these fields are too narrow for him.}" In this task, you certainly do not have to prove this theorem, it is only necessary for a given natural number \textbf{n} define the number of ways it can be represented as the sum of two powers of natural numbers with exponent \textbf{k}. In other words, as there are unordered pairs of integers \textbf{(x, y)}, which satisfy the equation: \textbf{x^k + y^k = n} \InputFile The input file contains a pair of numbers \textbf{n}, \textbf{k} (\textbf{1} ≤ \textbf{n} ≤ \textbf{10^18}, \textbf{1} ≤ \textbf{k} ≤ \textbf{100}). \OutputFile Bring a single number - the number of solutions.
Time limit 0.5 seconds
Memory limit 64 MiB
Input example #1
10 2
Output example #1
1
Author Evgeniy Sluzhaev