import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        }
    }
} import java.io.InputStream; InputStream java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        }
    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) Solver solver = new Solver(); solver new Solver() solver.solve(in, out) solver.solve solver in out out.close() out.close out String[] args args static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        }
    } Solver public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        } solve {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        } long H = in.nextLong(); H in.nextLong() in.nextLong in long count = 0; count 0 long loop = 0; loop 0 do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1); H >= 1 H 1 {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            } count += Math.pow(2, loop) count Math.pow(2, loop) Math.pow Math 2 loop loop++ loop H /= 2 H 2 out.println(count) out.println out count Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        }
    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        }
    }
} Main
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        }
    }
}