def main(): N = int(input()) hit = 0 biscuit = 1 while biscuit * 2 < N: biscuit = biscuit * 2 hit += 1 if (N - biscuit) >= 2: hit += ((N - biscuit) & 1) + 1 elif (N - biscuit) == 1: hit += 1 print(hit) if __name__ == '__main__': main()