import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long multiple = 1;
		while(h > 0) {
			h = h / 2;
			multiple *= 2;
		}
		System.out.println(multiple - 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();
		long multiple = 1;
		while(h > 0) {
			h = h / 2;
			multiple *= 2;
		}
		System.out.println(multiple - 1);

	}


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

	} main {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long multiple = 1;
		while(h > 0) {
			h = h / 2;
			multiple *= 2;
		}
		System.out.println(multiple - 1);

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

	}


} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long multiple = 1;
		while(h > 0) {
			h = h / 2;
			multiple *= 2;
		}
		System.out.println(multiple - 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();
		long multiple = 1;
		while(h > 0) {
			h = h / 2;
			multiple *= 2;
		}
		System.out.println(multiple - 1);

	}


}

