import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long health = scanner.nextLong();

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long health = scanner.nextLong();

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long health = scanner.nextLong();

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    } main {
        Scanner scanner = new Scanner(System.in);
        long health = scanner.nextLong();

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) long health = scanner.nextLong(); health scanner.nextLong() scanner.nextLong scanner long sum = 0; sum 0 long k = 1; k 1 for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        } long i = health; long i = health; i health i > 0 i 0 {
            i /= 2;
            sum += k;
            k *= 2;
        } {
            i /= 2;
            sum += k;
            k *= 2;
        } i /= 2 i 2 sum += k sum k k *= 2 k 2 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long health = scanner.nextLong();

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long health = scanner.nextLong();

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long health = scanner.nextLong();

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    }
}