#include int gcd(int a,int b){ return b?gcd(b,a%b):a; } int main(){ long long n; scanf("%lld",&n); int cnt = 0; while(n!=1){ //printf("n = %lld\n",n); if(n==3){ cnt += 3; n = 1; } else{ cnt += 2; n = n/2+n%2; } } printf("%d\n",cnt); return 0; }