eolymp
Competitions

Full Search

2-variable Function

Given an integer n, find the smallest integer x that satisfies two conditions:

  • x is greater than or equal to n;
  • There is a pair of non-negative integers (a, b) such that x = a3 + a2 * b + a * b2 + b3.

Input

One nonnegative integer n (n1018).

Output

Print the smallest value of x.

Time limit 1 second
Memory limit 128 MiB
Input example #1
9
Output example #1
15
Input example #2
0
Output example #2
0