import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final long h = sc.nextLong();
        
        System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1);
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final long h = sc.nextLong();
        
        System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1);
    }

} Main public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final long h = sc.nextLong();
        
        System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1);
    } main {
        final Scanner sc = new Scanner(System.in);

        final long h = sc.nextLong();
        
        System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1) System.out.println System.out System System.out (long)Math.pow(2, Long.toBinaryString(h).length()) - 1 (long)Math.pow(2, Long.toBinaryString(h).length()) Math.pow Math 2 Long.toBinaryString(h).length() Long.toBinaryString(h).length Long.toBinaryString(h) Long.toBinaryString Long h 1 String[] args args public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final long h = sc.nextLong();
        
        System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1);
    }

} public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final long h = sc.nextLong();
        
        System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1);
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final long h = sc.nextLong();
        
        System.out.println((long)Math.pow(2, Long.toBinaryString(h).length()) - 1);
    }

}
