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