import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int sum = 0;
		long a = 1;
		long b = 0;
		sc.close();

		while (H > 1) {
			H = H / 2;
			sum++;
		}
		for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		}
		System.out.println(b + 1);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int sum = 0;
		long a = 1;
		long b = 0;
		sc.close();

		while (H > 1) {
			H = H / 2;
			sum++;
		}
		for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		}
		System.out.println(b + 1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int sum = 0;
		long a = 1;
		long b = 0;
		sc.close();

		while (H > 1) {
			H = H / 2;
			sum++;
		}
		for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		}
		System.out.println(b + 1);
	} main {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int sum = 0;
		long a = 1;
		long b = 0;
		sc.close();

		while (H > 1) {
			H = H / 2;
			sum++;
		}
		for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		}
		System.out.println(b + 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc int sum = 0; sum 0 long a = 1; a 1 long b = 0; b 0 sc.close() sc.close sc while (H > 1) {
			H = H / 2;
			sum++;
		} H > 1 H 1 {
			H = H / 2;
			sum++;
		} H = H / 2 H H / 2 H 2 sum++ sum for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		} int i = 0; int i = 0; i 0 i < sum i sum i++ i++ i {
			a = 2 * a;
			b += a;
		} {
			a = 2 * a;
			b += a;
		} a = 2 * a a 2 * a 2 a b += a b a System.out.println(b + 1) System.out.println System.out System System.out b + 1 b 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int sum = 0;
		long a = 1;
		long b = 0;
		sc.close();

		while (H > 1) {
			H = H / 2;
			sum++;
		}
		for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		}
		System.out.println(b + 1);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int sum = 0;
		long a = 1;
		long b = 0;
		sc.close();

		while (H > 1) {
			H = H / 2;
			sum++;
		}
		for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		}
		System.out.println(b + 1);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int sum = 0;
		long a = 1;
		long b = 0;
		sc.close();

		while (H > 1) {
			H = H / 2;
			sum++;
		}
		for (int i = 0; i < sum; i++) {
			a = 2 * a;
			b += a;
		}
		System.out.println(b + 1);
	}
}
