		
		import java.util.Scanner;

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