import sys sys.setrecursionlimit(5*10**5) dic = {} def dfs(x): if x in dic: return dic[x] if x == 1: return 0 cand = 10**10 now = x if x%2: cand = min(cand,1+dfs(x+1)) else: while now%2 == 0: now //= 2 cand = min(cand,1+dfs(now)) dic[x] = cand return cand print(dfs(int(input()))) # print(dic)