#include<bits/stdc++.h>
using namespace std ;
int mini(int a,int b,int c)
{
return min(a,min(b,c)) ;
}
int solve(int x)
{
int dp[x+1]={0};
dp[1]=0;
dp[2]=1;
int i = 3 ;
while(i<=x)
{
if(i%7==0)
{
dp[i]=mini(dp[i-1]+1,dp[i-2]+1,dp[i/7]+ 1) ;
}
else
{
dp[i]=min(dp[i-1]+1,dp[i-2]+1) ;
}
i++;
}
return dp[x] ;
}
int main()
{
int x = 93 ;
cout<<"Minimum number of steps required to make the given number to 1"<<solve(x);
return 0 ;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZCA7CgppbnQgbWluaShpbnQgYSxpbnQgYixpbnQgYykKewogICAgcmV0dXJuIG1pbihhLG1pbihiLGMpKSA7IAp9CgppbnQgc29sdmUoaW50IHgpCnsKICAgIGludCBkcFt4KzFdPXswfTsKICAgIGRwWzFdPTA7CiAgICBkcFsyXT0xOwogICAgaW50IGkgPSAzIDsgCiAgICB3aGlsZShpPD14KQogICAgewogICAgICAgIGlmKGklNz09MCkKICAgICAgICB7CiAgICAgICAgICAgIGRwW2ldPW1pbmkoZHBbaS0xXSsxLGRwW2ktMl0rMSxkcFtpLzddKyAxKSA7IAogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICBkcFtpXT1taW4oZHBbaS0xXSsxLGRwW2ktMl0rMSkgOyAKICAgICAgICB9CiAgICAgICAgaSsrOwogICAgfQogICAgcmV0dXJuIGRwW3hdIDsgCn0KaW50IG1haW4oKQp7CiAgICAKICAgIGludCB4ID0gOTMgOyAKICAgIGNvdXQ8PCJNaW5pbXVtIG51bWJlciBvZiBzdGVwcyByZXF1aXJlZCB0byBtYWtlIHRoZSBnaXZlbiBudW1iZXIgdG8gMSI8PHNvbHZlKHgpOwogICAgCiAgICByZXR1cm4gMCA7Cn0=