import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        long count = 1;
        int i = 1;
        while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        }
        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        long count = 1;
        int i = 1;
        while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        long count = 1;
        int i = 1;
        while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        long count = 1;
        int i = 1;
        while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = Long.parseLong(sc.next()); H Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long count = 1; count 1 int i = 1; i 1 while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        } H > 1 H 1 {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        } H /= 2 H 2 count += Math.pow(2, i) count Math.pow(2, i) Math.pow Math 2 i i++ i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        long count = 1;
        int i = 1;
        while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        long count = 1;
        int i = 1;
        while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        }
        System.out.println(count);
    }
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        long count = 1;
        int i = 1;
        while(H > 1) {
            H /= 2;
            count += Math.pow(2, i);
            i++;
        }
        System.out.println(count);
    }
}