import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        long h = sc.nextLong();

        // 処理
        long cnt = 1;
        long out = 0;
        while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        }
        out += cnt;

        // 出力
        System.out.println(out);
    }
} import java.util.*; util.* java import javax.lang.model.util.ElementScanner6; ElementScanner6 javax.lang.model.util public class Main {

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

        // 入力
        long h = sc.nextLong();

        // 処理
        long cnt = 1;
        long out = 0;
        while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        }
        out += cnt;

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

        // 入力
        long h = sc.nextLong();

        // 処理
        long cnt = 1;
        long out = 0;
        while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        }
        out += cnt;

        // 出力
        System.out.println(out);
    } main {
        Scanner sc = new Scanner(System.in);

        // 入力
        long h = sc.nextLong();

        // 処理
        long cnt = 1;
        long out = 0;
        while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        }
        out += cnt;

        // 出力
        System.out.println(out);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long cnt = 1; cnt 1 long out = 0; out 0 while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        } h > 1 h 1 {
            out += cnt;
            h /= 2;
            cnt *= 2;
        } out += cnt out cnt h /= 2 h 2 cnt *= 2 cnt 2 out += cnt out cnt System.out.println(out) System.out.println System.out System System.out out String[] args args public class Main {

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

        // 入力
        long h = sc.nextLong();

        // 処理
        long cnt = 1;
        long out = 0;
        while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        }
        out += cnt;

        // 出力
        System.out.println(out);
    }
} public class Main {

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

        // 入力
        long h = sc.nextLong();

        // 処理
        long cnt = 1;
        long out = 0;
        while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        }
        out += cnt;

        // 出力
        System.out.println(out);
    }
} Main
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        long h = sc.nextLong();

        // 処理
        long cnt = 1;
        long out = 0;
        while (h > 1) {
            out += cnt;
            h /= 2;
            cnt *= 2;
        }
        out += cnt;

        // 出力
        System.out.println(out);
    }
}