import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long sum=0;
        for(int i=1;i<H+100;i++) {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        }
        
        System.out.println(sum);
        		
    }
} import java.util.*; util.* java import java.util.Map.Entry; Entry java.util.Map class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long sum=0;
        for(int i=1;i<H+100;i++) {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        }
        
        System.out.println(sum);
        		
    }
} Main static int mod =  (int) (Math.pow(10,9)+7); mod (int) (Math.pow(10,9)+7) Math.pow(10,9) Math.pow Math 10 9 7 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>(); list new ArrayList<ArrayList<Integer>>() public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long sum=0;
        for(int i=1;i<H+100;i++) {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        }
        
        System.out.println(sum);
        		
    } main {
    
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long sum=0;
        for(int i=1;i<H+100;i++) {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        }
        
        System.out.println(sum);
        		
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long sum=0; sum 0 for(int i=1;i<H+100;i++) {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        } int i=1; int i=1; i 1 i<H+100 i H+100 H 100 i++ i++ i {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        } {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        } if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	} H<(long)Math.pow(2, i) H (long)Math.pow(2, i) Math.pow Math 2 i {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	} sum = (long)Math.pow(2,i)-1 sum (long)Math.pow(2,i)-1 (long)Math.pow(2,i) Math.pow Math 2 i 1 break; System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long sum=0;
        for(int i=1;i<H+100;i++) {
        	if(H<(long)Math.pow(2, i)) {
        	   sum = (long)Math.pow(2,i)-1;
        	   break;
        	}
        }
        
        System.out.println(sum);
        		
    }
}