import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int times = 0;
        while (H > 1) {
            times++;
            H >>= 1;
        }
        long result = 0;
        for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int times = 0;
        while (H > 1) {
            times++;
            H >>= 1;
        }
        long result = 0;
        for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int times = 0;
        while (H > 1) {
            times++;
            H >>= 1;
        }
        long result = 0;
        for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        }
        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int times = 0;
        while (H > 1) {
            times++;
            H >>= 1;
        }
        long result = 0;
        for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        }
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc int times = 0; times 0 while (H > 1) {
            times++;
            H >>= 1;
        } H > 1 H 1 {
            times++;
            H >>= 1;
        } times++ times H >>= 1 H 1 long result = 0; result 0 for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        } int i = 0; int i = 0; i 0 i<=times i times ++i ++i i {
            result += Math.pow(2, i);
        } {
            result += Math.pow(2, i);
        } result += Math.pow(2, i) result Math.pow(2, i) Math.pow Math 2 i System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int times = 0;
        while (H > 1) {
            times++;
            H >>= 1;
        }
        long result = 0;
        for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int times = 0;
        while (H > 1) {
            times++;
            H >>= 1;
        }
        long result = 0;
        for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int times = 0;
        while (H > 1) {
            times++;
            H >>= 1;
        }
        long result = 0;
        for (int i = 0; i<=times; ++i){
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
}
