https://www.acmicpc.net/problem/1463
#include<stdio.h>
static int min(int a,int b){
return a<=b?a:b;
}
int main() {
int n;
scanf("%d",&n);
int arr[n+1];
arr[1]=0;
for(int i=2;i<=n;i++){
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]);
}
printf("%d",arr[n]);
}