import java.util.*;


public class Main{
    static long count=0;
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long sum=0;
        int i=0;
        while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        }
        //sum=sum+Math.pow(2, i);
        System.out.println(sum);
        
    }
} import java.util.*; util.* java public class Main{
    static long count=0;
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long sum=0;
        int i=0;
        while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        }
        //sum=sum+Math.pow(2, i);
        System.out.println(sum);
        
    }
} Main static long count=0; count 0 public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long sum=0;
        int i=0;
        while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        }
        //sum=sum+Math.pow(2, i);
        System.out.println(sum);
        
    } main {
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long sum=0;
        int i=0;
        while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        }
        //sum=sum+Math.pow(2, i);
        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 int i=0; i 0 while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        } H>sum H sum {
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        } sum=sum+(long)Math.pow(2, i) sum sum+(long)Math.pow(2, i) sum (long)Math.pow(2, i) Math.pow Math 2 i i++ i System.out.println(sum) System.out.println System.out System System.out sum String [] args args public class Main{
    static long count=0;
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long sum=0;
        int i=0;
        while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        }
        //sum=sum+Math.pow(2, i);
        System.out.println(sum);
        
    }
} public class Main{
    static long count=0;
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long sum=0;
        int i=0;
        while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        }
        //sum=sum+Math.pow(2, i);
        System.out.println(sum);
        
    }
} Main
import java.util.*;


public class Main{
    static long count=0;
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long sum=0;
        int i=0;
        while(H>sum){
            
            sum=sum+(long)Math.pow(2, i);
            i++;
        }
        //sum=sum+Math.pow(2, i);
        System.out.println(sum);
        
    }
}
