import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;
        long count2 = 1;
        while (H != 0) {
            count += count2;
            count2 *= 2;
            H /= 2;
        }

        System.out.println(count);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;
        long count2 = 1;
        while (H != 0) {
            count += count2;
            count2 *= 2;
            H /= 2;
        }

        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;
        long count2 = 1;
        while (H != 0) {
            count += count2;
            count2 *= 2;
            H /= 2;
        }

        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;
        long count2 = 1;
        while (H != 0) {
            count += count2;
            count2 *= 2;
            H /= 2;
        }

        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long count = 0; count 0 long count2 = 1; count2 1 while (H != 0) {
            count += count2;
            count2 *= 2;
            H /= 2;
        } H != 0 H 0 {
            count += count2;
            count2 *= 2;
            H /= 2;
        } count += count2 count count2 count2 *= 2 count2 2 H /= 2 H 2 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;
        long count2 = 1;
        while (H != 0) {
            count += count2;
            count2 *= 2;
            H /= 2;
        }

        System.out.println(count);
    }
}