import java.util.*;

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

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