main = interact $ unlines . map (show . coconut_grab . read) . init . lines
 
coconut_grab e = (minimum . map sum) cands
 where
  cands = [[x,y,z] | let z' = (floor.cbrt.fromIntegral) e, z<-[0..z'],
                     let y' = (floor.sqrt.fromIntegral) (e-z^3), y<-[0..y'], x<-[0..e-z^3-y^2],
                     x + y^2 + z^3 == e]

cbrt q = until approx (\q' -> q' - (q'^3-q) / (3*q'^2)) (q/2)
 where approx x = abs (x^3 - q) < 0.00001*q