main = interact $ unlines . map (show . coconut_grab . read) . init . lines
 
coconut_grab e = (minimum . map sum) cand
 where cand = [[x,y,z] | let z' = (floor.cbrt.fromIntegral) e, let y' = (floor.sqrt.fromIntegral) e, let x' = e,
                         z<-[z',z'-1..0], y<-[y',y'-1..0], x<-[x',x'-1..0], 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