import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long h = Long.parseLong(scanner.next());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    }
} 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());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long h = Long.parseLong(scanner.next());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    } main {
        Scanner scanner = new Scanner(System.in);
        long h = Long.parseLong(scanner.next());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    } 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 long x = 1; x 1 long atc = 0; atc 0 for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        } int i = 0; int i = 0; i 0 true i++ i++ i {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        } {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        } h = h / 2 h h / 2 h 2 atc = atc + x atc atc + x atc x x = x * 2 x x * 2 x 2 if (h == 0) {
                System.out.println(atc);
                break;
            } h == 0 h 0 {
                System.out.println(atc);
                break;
            } System.out.println(atc) System.out.println System.out System System.out atc break; String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long h = Long.parseLong(scanner.next());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long h = Long.parseLong(scanner.next());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long h = Long.parseLong(scanner.next());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    }
}