sub f{$x%$_||f(local$x=$x/$_)for$_||2..$x**(1/$n)*!!--$n+.5;$%+=!$n++}print f$x=<>=~$"+$',$n=$`