import java.util.Scanner;

public class Main {

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());
        int n = 0;
        while (h > 0) {
            n++;
            h /= 2;
        }
        System.out.println((long)Math.pow(2, n) - 1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());
        int n = 0;
        while (h > 0) {
            n++;
            h /= 2;
        }
        System.out.println((long)Math.pow(2, n) - 1);
    } main {
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());
        int n = 0;
        while (h > 0) {
            n++;
            h /= 2;
        }
        System.out.println((long)Math.pow(2, n) - 1);
    } 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 int n = 0; n 0 while (h > 0) {
            n++;
            h /= 2;
        } h > 0 h 0 {
            n++;
            h /= 2;
        } n++ n h /= 2 h 2 System.out.println((long)Math.pow(2, n) - 1) System.out.println System.out System System.out (long)Math.pow(2, n) - 1 (long)Math.pow(2, n) Math.pow Math 2 n 1 String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());
        int n = 0;
        while (h > 0) {
            n++;
            h /= 2;
        }
        System.out.println((long)Math.pow(2, n) - 1);
    }
} public class Main {

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());
        int n = 0;
        while (h > 0) {
            n++;
            h /= 2;
        }
        System.out.println((long)Math.pow(2, n) - 1);
    }
}
