import java.io.*;
import java.util.*;

public class Main {

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

        final Solver solver = new Solver();
        solver.solve(H);
    }
}

class Solver {
    public void solve(long H) {
        long i = 0;
        while (H > 0) {
            i++;
            H /= 2;
        }

        System.out.println((long) (Math.pow(2, i) - 1));
    }
}
 import java.io.*; io.* java import java.util.*; util.* java public class Main {

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

        final Solver solver = new Solver();
        solver.solve(H);
    }
} Main public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long H;
        H = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(H);
    } main {
        final Scanner sc = new Scanner(System.in);
        long H;
        H = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(H);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H; H H = sc.nextLong() H sc.nextLong() sc.nextLong sc final Solver solver = new Solver(); solver new Solver() solver.solve(H) solver.solve solver H final String[] args args class Solver {
    public void solve(long H) {
        long i = 0;
        while (H > 0) {
            i++;
            H /= 2;
        }

        System.out.println((long) (Math.pow(2, i) - 1));
    }
} Solver public void solve(long H) {
        long i = 0;
        while (H > 0) {
            i++;
            H /= 2;
        }

        System.out.println((long) (Math.pow(2, i) - 1));
    } solve {
        long i = 0;
        while (H > 0) {
            i++;
            H /= 2;
        }

        System.out.println((long) (Math.pow(2, i) - 1));
    } long i = 0; i 0 while (H > 0) {
            i++;
            H /= 2;
        } H > 0 H 0 {
            i++;
            H /= 2;
        } i++ i H /= 2 H 2 System.out.println((long) (Math.pow(2, i) - 1)) System.out.println System.out System System.out (long) (Math.pow(2, i) - 1) Math.pow(2, i) Math.pow Math 2 i 1 long H H public class Main {

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

        final Solver solver = new Solver();
        solver.solve(H);
    }
} public class Main {

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

        final Solver solver = new Solver();
        solver.solve(H);
    }
} Main
import java.io.*;
import java.util.*;

public class Main {

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

        final Solver solver = new Solver();
        solver.solve(H);
    }
}

class Solver {
    public void solve(long H) {
        long i = 0;
        while (H > 0) {
            i++;
            H /= 2;
        }

        System.out.println((long) (Math.pow(2, i) - 1));
    }
}

