main = interact $ unlines . map (show . coconut_grab . read) . init . lines

coconut_grab :: Int -> Int
coconut_grab e = coconut_grab_z e 0 ((ceiling.cbrt.fromIntegral) e)
 where
  coconut_grab_z e' n x
   | x == 0 =  coconut_grab_y e' x ((ceiling.sqrt.fromIntegral) e')
   | x^3 == e' = x
   | x^3 > e' = coconut_grab_z e' n (x-1)
   | otherwise = coconut_grab_y (e'-x^3) x ((ceiling.sqrt.fromIntegral) (e'-x^3)) `min` coconut_grab_z e' n (x-1)
  
  coconut_grab_y e' n x
   | x^2 == e' = n + x
   | x^2 > e' = coconut_grab_y e' n (x-1)
   | otherwise = n + x + (e'-x^2)
                       
cbrt q = until approx (\q' -> q' - (q'^3-q) / (3*q'^2)) (q/2)
 where approx x = abs (x^3 - q) < 0.00001*q