import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long H = scan.nextLong();
		long count = 0;
		long sum = 1;

		while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long H = scan.nextLong();
		long count = 0;
		long sum = 1;

		while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long H = scan.nextLong();
		long count = 0;
		long sum = 1;

		while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		}
		System.out.println(count);
	} main {

		Scanner scan = new Scanner(System.in);

		long H = scan.nextLong();
		long count = 0;
		long sum = 1;

		while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		}
		System.out.println(count);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long H = scan.nextLong(); H scan.nextLong() scan.nextLong scan long count = 0; count 0 long sum = 1; sum 1 while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		} H > 0 H 0 {

			H /= 2;
			count += sum;
			sum *= 2;
		} H /= 2 H 2 count += sum count sum sum *= 2 sum 2 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long H = scan.nextLong();
		long count = 0;
		long sum = 1;

		while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long H = scan.nextLong();
		long count = 0;
		long sum = 1;

		while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long H = scan.nextLong();
		long count = 0;
		long sum = 1;

		while(H > 0) {

			H /= 2;
			count += sum;
			sum *= 2;
		}
		System.out.println(count);
	}
}