N = int(input()) i = 1 ans = 0 while i < N: i *= 2 ans += 1 print(ans + bin(i-N).count('1'))