import sys int1 = lambda x: int(x) - 1 # input = lambda: sys.stdin.buffer.readline() input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) i1 = lambda: int1(input()) mi = lambda: map(int, input().split()) mi1 = lambda: map(int1, input().split()) li = lambda: list(mi()) li1 = lambda: list(mi1()) lli = lambda n: [li() for _ in range(n)] INF = float("inf") # mod = int(1e9 + 7) mod = 998244353 def f(n): if n == 1: return 0 res = INF m = 0 for j in range(100): if n == (1 << j): res = min(res, 1) if (1 << j) > n and ((1 << j) - 1) % n == 0: res = min(res, 2) if n % (1 << j) == 0: m = max(m, j) if m > 0: res = min(res, 1 + f(n >> m)) return res print(f(ii()))