N=int(eval(input()))

NB=format(N,'0b')

K=len(NB)

print((2**K-1))

#!/usr/bin python3

# -*- coding: utf-8 -*-



def cnt(hp):

    if hp == 1:

        return 1

    else:

        return 2 * cnt(hp//2) + 1



def main():

    H = int(eval(input()))

    print((cnt(H)))



if __name__ == '__main__':

    main()
N = int(eval(input()))
NB = format(N, "0b")
K = len(NB)
print((2**K - 1))

#!/usr/bin python3
# -*- coding: utf-8 -*-
def cnt(hp):
    if hp == 1:
        return 1
    else:
        return 2 * cnt(hp // 2) + 1


def main():
    H = int(eval(input()))
    print((cnt(H)))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -NB = format(N, "0b") -K = len(NB) -print((2**K - 1)) +#!/usr/bin python3 +# -*- coding: utf-8 -*- +def cnt(hp): +    if hp == 1: +        return 1 +    else: +        return 2 * cnt(hp // 2) + 1 + + +def main(): +    H = int(eval(input())) +    print((cnt(H))) + + +if __name__ == "__main__": +    main()