m@main=readLn>>=print.f>>m f 1=1 f n=maximum[f x|x<-[1..n-1],mod n x<1]+sum[read[a]|a<-show n]