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