import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    }

}



 import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    }

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

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    } main {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long ans = 0; ans 0 long count =0; count 0 long life = H; life H while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        } life != 0 life 0 {
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        } life = life / 2 life life / 2 life 2 ans += Math.pow(2,count) ans Math.pow(2,count) Math.pow Math 2 count count++ count System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    }

} Main
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    }

}




