import java.util.Arrays;
import java.util.Scanner;

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

        long health = in.nextLong();
        long attacks, div = 0;

        while (health > 1) {
            div++;
            health /= 2;
        }

        attacks = 2 * (long) Math.pow(2, div) - 1;

        System.out.println(attacks);

        in.close();

    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long health = in.nextLong();
        long attacks, div = 0;

        while (health > 1) {
            div++;
            health /= 2;
        }

        attacks = 2 * (long) Math.pow(2, div) - 1;

        System.out.println(attacks);

        in.close();

    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long health = in.nextLong();
        long attacks, div = 0;

        while (health > 1) {
            div++;
            health /= 2;
        }

        attacks = 2 * (long) Math.pow(2, div) - 1;

        System.out.println(attacks);

        in.close();

    } main {
        Scanner in = new Scanner(System.in);

        long health = in.nextLong();
        long attacks, div = 0;

        while (health > 1) {
            div++;
            health /= 2;
        }

        attacks = 2 * (long) Math.pow(2, div) - 1;

        System.out.println(attacks);

        in.close();

    } Scanner in = new Scanner(System.in); in new Scanner(System.in) long health = in.nextLong(); health in.nextLong() in.nextLong in long attacks attacks div = 0; div 0 while (health > 1) {
            div++;
            health /= 2;
        } health > 1 health 1 {
            div++;
            health /= 2;
        } div++ div health /= 2 health 2 attacks = 2 * (long) Math.pow(2, div) - 1 attacks 2 * (long) Math.pow(2, div) - 1 2 * (long) Math.pow(2, div) 2 (long) Math.pow(2, div) Math.pow Math 2 div 1 System.out.println(attacks) System.out.println System.out System System.out attacks in.close() in.close in String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long health = in.nextLong();
        long attacks, div = 0;

        while (health > 1) {
            div++;
            health /= 2;
        }

        attacks = 2 * (long) Math.pow(2, div) - 1;

        System.out.println(attacks);

        in.close();

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

        long health = in.nextLong();
        long attacks, div = 0;

        while (health > 1) {
            div++;
            health /= 2;
        }

        attacks = 2 * (long) Math.pow(2, div) - 1;

        System.out.println(attacks);

        in.close();

    }
} Main
import java.util.Arrays;
import java.util.Scanner;

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

        long health = in.nextLong();
        long attacks, div = 0;

        while (health > 1) {
            div++;
            health /= 2;
        }

        attacks = 2 * (long) Math.pow(2, div) - 1;

        System.out.println(attacks);

        in.close();

    }
}
