import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        long ans = 1;
        int cnt = 1;
        while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        }
        System.out.println(ans);
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        long ans = 1;
        int cnt = 1;
        while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        }
        System.out.println(ans);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        long ans = 1;
        int cnt = 1;
        while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        long ans = 1;
        int cnt = 1;
        while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc long ans = 1; ans 1 int cnt = 1; cnt 1 while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        } h > 1 h 1 {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        } h = Math.floor(h / 2) h Math.floor(h / 2) Math.floor Math h / 2 h 2 ans += Math.pow(2, cnt) ans Math.pow(2, cnt) Math.pow Math 2 cnt cnt++ cnt 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);
        double h = sc.nextDouble();
        long ans = 1;
        int cnt = 1;
        while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        }
        System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        long ans = 1;
        int cnt = 1;
        while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        }
        System.out.println(ans);
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        long ans = 1;
        int cnt = 1;
        while (h > 1) {
            h = Math.floor(h / 2);
            ans += Math.pow(2, cnt);
            cnt++;
        }
        System.out.println(ans);
    }

}
