import java.util.Scanner;

// D - Caracal vs Monster
// https://atcoder.jp/contests/abc153/tasks/abc153_d
public class Main {

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

        System.out.println(f(H));
    }

    private static long f(long H) {
        if (H == 1) return 1;
        return f(H / 2) * 2 + 1;
    }
} import java.util.Scanner; Scanner java.util public class Main {

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

        System.out.println(f(H));
    }

    private static long f(long H) {
        if (H == 1) return 1;
        return f(H / 2) * 2 + 1;
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long H = Long.parseLong(scanner.next());
        scanner.close();

        System.out.println(f(H));
    } main {
        Scanner scanner = new Scanner(System.in);
        long H = Long.parseLong(scanner.next());
        scanner.close();

        System.out.println(f(H));
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) long H = Long.parseLong(scanner.next()); H Long.parseLong(scanner.next()) Long.parseLong Long scanner.next() scanner.next scanner scanner.close() scanner.close scanner System.out.println(f(H)) System.out.println System.out System System.out f(H) f H String[] args args private static long f(long H) {
        if (H == 1) return 1;
        return f(H / 2) * 2 + 1;
    } f {
        if (H == 1) return 1;
        return f(H / 2) * 2 + 1;
    } if (H == 1) return 1; H == 1 H 1 return 1; 1 return f(H / 2) * 2 + 1; f(H / 2) * 2 + 1 f(H / 2) * 2 f(H / 2) f H / 2 H 2 2 1 long H H public class Main {

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

        System.out.println(f(H));
    }

    private static long f(long H) {
        if (H == 1) return 1;
        return f(H / 2) * 2 + 1;
    }
} public class Main {

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

        System.out.println(f(H));
    }

    private static long f(long H) {
        if (H == 1) return 1;
        return f(H / 2) * 2 + 1;
    }
} Main
import java.util.Scanner;

// D - Caracal vs Monster
// https://atcoder.jp/contests/abc153/tasks/abc153_d
public class Main {

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

        System.out.println(f(H));
    }

    private static long f(long H) {
        if (H == 1) return 1;
        return f(H / 2) * 2 + 1;
    }
}
