https://www.acmicpc.net/problem/1463
import java.util.Scanner
import kotlin.math.*
fun main(args: Array<String>){
val sc: Scanner = Scanner(System.`in`)
var n = sc.nextInt()
var arr=Array<Int>(n+1,{0})
for(i in 2..n){
arr[i]=arr[i-1]+1
if(i%6==0) arr[i]=min(min(arr[i/3]+1,arr[i/2]+1),arr[i])
else if(i%3==0) arr[i]=min(arr[i/3]+1,arr[i]);
else if(i%2==0) arr[i]=min(arr[i/2]+1,arr[i]);
}
print(arr[n])
}