import java.util.*;
public class Main {
	public static void main(String[] args) {
		long H = new Scanner(System.in).nextLong(), ans = 1;
		for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2;
		System.out.println(ans-1);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		long H = new Scanner(System.in).nextLong(), ans = 1;
		for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2;
		System.out.println(ans-1);
	}
} Main public static void main(String[] args) {
		long H = new Scanner(System.in).nextLong(), ans = 1;
		for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2;
		System.out.println(ans-1);
	} main {
		long H = new Scanner(System.in).nextLong(), ans = 1;
		for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2;
		System.out.println(ans-1);
	} long H = new Scanner(System.in).nextLong() H new Scanner(System.in).nextLong() new Scanner(System.in).nextLong new Scanner(System.in) ans = 1; ans 1 for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2; int i = 0; int i = 0; i 0 i < (int) (Math.log(H) / Math.log(2)) + 1 i (int) (Math.log(H) / Math.log(2)) + 1 (int) (Math.log(H) / Math.log(2)) Math.log(H) Math.log Math H Math.log(2) Math.log Math 2 1 i++ i++ i ans *= 2; ans *= 2 ans 2 System.out.println(ans-1) System.out.println System.out System System.out ans-1 ans 1 String[] args args public class Main {
	public static void main(String[] args) {
		long H = new Scanner(System.in).nextLong(), ans = 1;
		for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2;
		System.out.println(ans-1);
	}
} public class Main {
	public static void main(String[] args) {
		long H = new Scanner(System.in).nextLong(), ans = 1;
		for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2;
		System.out.println(ans-1);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		long H = new Scanner(System.in).nextLong(), ans = 1;
		for(int i = 0; i < (int) (Math.log(H) / Math.log(2)) + 1; i++)
			ans *= 2;
		System.out.println(ans-1);
	}
}
