def main(): N = int(input()) X = 1 cnt = 0 while N > X: X *= 2 cnt += 1 cnt += X - N print(cnt) if __name__ == "__main__": main()