import java.util.Scanner;
import java.util.ArrayList;

public class Main{
    Scanner scan = new Scanner(System.in);
    long H;

    Main(){
        H = scan.nextLong();
        System.out.println(f(H));
    }
    public long f(long H){
        if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        }
        
    }


    public static void main(String[] args){
        new Main();
    }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main{
    Scanner scan = new Scanner(System.in);
    long H;

    Main(){
        H = scan.nextLong();
        System.out.println(f(H));
    }
    public long f(long H){
        if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        }
        
    }


    public static void main(String[] args){
        new Main();
    }
} Main Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long H; H Main(){
        H = scan.nextLong();
        System.out.println(f(H));
    } Main {
        H = scan.nextLong();
        System.out.println(f(H));
    } H = scan.nextLong() H scan.nextLong() scan.nextLong scan System.out.println(f(H)) System.out.println System.out System System.out f(H) f H public long f(long H){
        if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        }
        
    } f {
        if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        }
        
    } if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        } H == 1 H 1 {return (long)1;} return (long)1; (long)1 {
            return 2*f(H/(long)2)+1;
        } return 2*f(H/(long)2)+1; 2*f(H/(long)2)+1 2*f(H/(long)2) 2 f(H/(long)2) f H/(long)2 H (long)2 1 long H H public static void main(String[] args){
        new Main();
    } main {
        new Main();
    } new Main() String[] args args public class Main{
    Scanner scan = new Scanner(System.in);
    long H;

    Main(){
        H = scan.nextLong();
        System.out.println(f(H));
    }
    public long f(long H){
        if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        }
        
    }


    public static void main(String[] args){
        new Main();
    }
} public class Main{
    Scanner scan = new Scanner(System.in);
    long H;

    Main(){
        H = scan.nextLong();
        System.out.println(f(H));
    }
    public long f(long H){
        if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        }
        
    }


    public static void main(String[] args){
        new Main();
    }
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
    Scanner scan = new Scanner(System.in);
    long H;

    Main(){
        H = scan.nextLong();
        System.out.println(f(H));
    }
    public long f(long H){
        if(H == 1){return (long)1;}
        else{
            return 2*f(H/(long)2)+1;
        }
        
    }


    public static void main(String[] args){
        new Main();
    }
}