import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long h = sc.nextLong();
		long c=1;
		long sum = 1;

		while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		}

		System.out.println(sum);

		return;

	}

}
 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();
		long c=1;
		long sum = 1;

		while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		}

		System.out.println(sum);

		return;

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long h = sc.nextLong();
		long c=1;
		long sum = 1;

		while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		}

		System.out.println(sum);

		return;

	} main {
		Scanner sc = new Scanner(System.in);
		Long h = sc.nextLong();
		long c=1;
		long sum = 1;

		while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		}

		System.out.println(sum);

		return;

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long c=1; c 1 long sum = 1; sum 1 while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		} h > 1 h 1 {
			h /= 2;
			c *= 2;
			sum += c;
		} h /= 2 h 2 c *= 2 c 2 sum += c sum c System.out.println(sum) System.out.println System.out System System.out sum return; String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long h = sc.nextLong();
		long c=1;
		long sum = 1;

		while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		}

		System.out.println(sum);

		return;

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long h = sc.nextLong();
		long c=1;
		long sum = 1;

		while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		}

		System.out.println(sum);

		return;

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long h = sc.nextLong();
		long c=1;
		long sum = 1;

		while(h > 1) {
			h /= 2;
			c *= 2;
			sum += c;
		}

		System.out.println(sum);

		return;

	}

}

