import java.util.Scanner;

public class Main {
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        long h = Long.parseLong(scan.next());
        long num = 1;
        long count = 0;
        while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        }
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        long h = Long.parseLong(scan.next());
        long num = 1;
        long count = 0;
        while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        }
        System.out.println(count);
    }
} Main public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        long h = Long.parseLong(scan.next());
        long num = 1;
        long count = 0;
        while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        }
        System.out.println(count);
    } main {
        Scanner scan = new Scanner(System.in);
        long h = Long.parseLong(scan.next());
        long num = 1;
        long count = 0;
        while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        }
        System.out.println(count);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long h = Long.parseLong(scan.next()); h Long.parseLong(scan.next()) Long.parseLong Long scan.next() scan.next scan long num = 1; num 1 long count = 0; count 0 while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        } h > 0 h 0 {
            h = h/2;
            count = count + num;
            num *= 2;
        } h = h/2 h h/2 h 2 count = count + num count count + num count num num *= 2 num 2 System.out.println(count) System.out.println System.out System System.out count String[] arg arg public class Main {
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        long h = Long.parseLong(scan.next());
        long num = 1;
        long count = 0;
        while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        long h = Long.parseLong(scan.next());
        long num = 1;
        long count = 0;
        while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        }
        System.out.println(count);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        long h = Long.parseLong(scan.next());
        long num = 1;
        long count = 0;
        while (h > 0) {
            h = h/2;
            count = count + num;
            num *= 2;
        }
        System.out.println(count);
    }
}