import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    } main {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) long H = Long.parseLong(s.next()); H Long.parseLong(s.next()) Long.parseLong Long s.next() s.next s int n = (int) (Math.log(H) / Math.log(2)); n (int) (Math.log(H) / Math.log(2)) Math.log(H) Math.log Math H Math.log(2) Math.log Math 2 System.out.println((long) Math.pow(2, n) * 2 - 1) System.out.println System.out System System.out (long) Math.pow(2, n) * 2 - 1 (long) Math.pow(2, n) * 2 (long) Math.pow(2, n) Math.pow Math 2 n 2 1 String[] args args public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    }
}