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;
        int tmp = 0;

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

        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;
        int tmp = 0;

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

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();

        long ans = 0;
        int tmp = 0;

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

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();

        long ans = 0;
        int tmp = 0;

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

        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 int tmp = 0; tmp 0 while(H != 0){
            H /= 2;
            ans += Math.pow(2,tmp);
            tmp++;
        } H != 0 H 0 {
            H /= 2;
            ans += Math.pow(2,tmp);
            tmp++;
        } H /= 2 H 2 ans += Math.pow(2,tmp) ans Math.pow(2,tmp) Math.pow Math 2 tmp tmp++ tmp 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;
        int tmp = 0;

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

        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;
        int tmp = 0;

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

        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;
        int tmp = 0;

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

        System.out.println(ans);
    }
}

