x, y = map(int, input().split())
t = ((x + (1 << y)) >> y) << y
for i in range(60):
	if t & (1 << i):
		print((1 << i) - 1)
		exit(0)