import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	}
} Main public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	} main {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	} try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		} {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long cnt = 1; cnt 1 while (cnt <= h) {
				cnt *= 2;
			} cnt <= h cnt h {
				cnt *= 2;
			} cnt *= 2 cnt 2 System.out.println(cnt - 1) System.out.println System.out System System.out cnt - 1 cnt 1 String[] args args public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	}
} public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	}
}
