import java.util.*;

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

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long h = scan.nextLong();
        long out = 1;
        while(h > 1){
            h = h / 2;
            out *= 2;
            out++;
        }
        System.out.println(out);
        scan.close();
    }
}