N = format(int(input()), 'b') L =len(N) - 1 hit = L + int(N[L]) if "1" in N[1:L-1]: hit += 1 print(hit)