Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! 

Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself, the next thief will take exactly k times more than the previous one. The value of k (k > 1) is a secret integer known only to them. It is also known that each thief's bag can carry at most n chocolates (if they intend to take more, the deal is cancelled) and that there were exactly four thieves involved. 

Sadly, only the thieves know the value of n, but rumours say that the numbers of ways they could have taken the chocolates (for a fixed n, but not fixed k) is m. Two ways are considered different if one of the thieves (they should be numbered in the order they take chocolates) took different number of chocolates in them.

Mike want to track the thieves down, so he wants to know what their bags are and value of n will help him in that. Please find the smallest possible value of n or tell him that the rumors are false and there is no such n.


-----Input-----

The single line of input contains the integer m (1 ≤ m ≤ 10^15) — the number of ways the thieves might steal the chocolates, as rumours say.


-----Output-----

Print the only integer n — the maximum amount of chocolates that thieves' bags can carry. If there are more than one n satisfying the rumors, print the smallest one.

If there is no such n for a false-rumoured m, print  - 1.


-----Examples-----
Input
1

Output
8

Input
8

Output
54

Input
10

Output
-1



-----Note-----

In the first sample case the smallest n that leads to exactly one way of stealing chocolates is n = 8, whereas the amounts of stealed chocolates are (1, 2, 4, 8) (the number of chocolates stolen by each of the thieves).

In the second sample case the smallest n that leads to exactly 8 ways is n = 54 with the possibilities: (1, 2, 4, 8),  (1, 3, 9, 27),  (2, 4, 8, 16),  (2, 6, 18, 54),  (3, 6, 12, 24),  (4, 8, 16, 32),  (5, 10, 20, 40),  (6, 12, 24, 48).

There is no n leading to exactly 10 ways of stealing chocolates in the third sample case.

Difficulty: MEDIUM_HARD
Tags: Sorting

Combinatorics

Mathematics
Skill types: Sorting

Starter code:

Solutions:
def get(x):
	ans = 0
	i = 2
	while i * i * i <= x:
		ans += x // (i * i * i)
		i += 1
	return ans
m = int(input())
n = 0
k = 1 << 60
while k != 0:
	if n + k <= 10 ** 16 and get(n + k) < m:
		n += k
	k //= 2
n += 1
if get(n) == m:
	print(n)
else:
	print(-1)


t = [k ** 3 for k in range(2, 170417)]
s = m = int(input())
(a, b) = (1, 9 * m)
while a < b:
	c = (a + b) // 2
	d = sum((int(c / k) for k in t))
	if d < m:
		a = c + 1
	else:
		(s, b) = (d, c)
print(a if s == m else -1)


n = int(input())
(l, r) = (0, 10 ** 16)
D = [x ** 3.0 for x in range(2, 170417)]
DD = [x * x * x for x in range(2, 170417)]
while l < r:
	m = (l + r) // 2
	if sum((int(m / d) for d in D)) < n:
		l = m + 1
	else:
		r = m
if sum((l // d for d in DD)) == n:
	print(l)
else:
	print(-1)


def main():
	m = int(input())
	if m < 1000000:
		lo = m * 4
		hi = m * 8
	else:
		lo = int(4.949 * m)
		hi = int(4.9492 * m)
	while lo < hi - 1:
		mid = (lo + hi) // 2
		nposs = countposs(mid)
		if nposs < m:
			lo = mid
		else:
			hi = mid
	if m == countposs(hi):
		print(hi)
	else:
		print(-1)

def countposs(maxtake):
	k = 2
	ans = 0
	while True:
		term = maxtake // (k * k * k)
		if term == 0:
			return ans
		ans += term
		k += 1
main()


cubes = [i ** 3.0 for i in range(2, int(180000.0 + 5))]

def valid(mid):
	return sum([mid // i for i in cubes if i <= mid])

def binary_search(k):
	l = int(4.8 * k)
	r = min(8.0 * k, 5.0 * 10 ** 15)
	while l + 1 < r:
		mid = (l + r) / 2.0
		res = valid(mid)
		if res < k:
			l = mid
		else:
			r = mid
	return int(r) if int(valid(r)) == k else -1

def main():
	k = int(input())
	print(binary_search(k))
main()


N = int(200000.0)
n = int(input())
cb = [x * x * x for x in range(2, N)]

def valid(m):
	return sum((m // i for i in cb)) < n

def binary_search():
	(l, r) = (0, int(1e+16))
	while l < r:
		m = (l + r) // 2
		if valid(m):
			l = m + 1
		else:
			r = m
	return l
res = binary_search()
print(res if sum((res // i for i in cb)) == n else -1)


def main():
	m = int(input())
	lo = m * 4
	hi = m * 8
	loposs = countposs(lo)
	hiposs = countposs(hi)
	while lo < hi - 1:
		if hi - lo > 10000:
			mid = lo + int((m - loposs) / (hiposs - loposs) * (hi - lo))
			mid = max(lo + 1, min(hi - 1, mid))
		else:
			mid = (hi + lo) // 2
		nposs = countposs(mid)
		if nposs < m:
			lo = mid
		else:
			hi = mid
	if m == countposs(hi):
		print(hi)
	else:
		print(-1)

def countposs(maxtake):
	k = 2
	ans = 0
	while True:
		term = maxtake // (k * k * k)
		if term == 0:
			return ans
		ans += term
		k += 1
main()


SIZE = 171000
L = [i ** 3 for i in range(SIZE)]

def get_count(n):
	MAX = int(n ** (1 / 3)) + 1
	if L[MAX] > n:
		MAX -= 1
	res = 0
	for i in range(2, MAX + 1):
		x = n // L[i]
		if x != 1:
			res += x
		else:
			res += MAX - i + 1
			break
	return res

def bin_search(m):
	beg = int(4.8 * m)
	end = min(8 * m, int(5000000000000000.0))
	while beg <= end:
		mid = (beg + end) // 2
		count_mid = get_count(mid)
		if count_mid == m:
			if beg == end:
				return mid
			end = mid
		elif count_mid > m:
			end = mid - 1
		else:
			beg = mid + 1
	return -1
m = int(input())
print(bin_search(m))


import math
from bisect import bisect_right, bisect_left
from collections import Counter, defaultdict
from heapq import heappop, heappush
from itertools import accumulate
R = lambda : map(int, input().split())
t = int(input())
tab = [x * x * x for x in range(2, 2 * 10 ** 5)]
(l, r) = (1, 5 * 10 ** 15)
while l < r:
	n = (l + r) // 2
	s = sum((n // x for x in tab))
	if s < t:
		l = n + 1
	elif s > t:
		r = n - 1
	else:
		r = n
s = sum((l // x for x in tab))
if s != t:
	print(-1)
else:
	print(l)