import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long sum = 0;
		long i = 1;

		if(h == 1) {
			System.out.println(1);
			System.exit(0);
		}

		do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1);

		sum += i;

		System.out.println(sum);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long sum = 0;
		long i = 1;

		if(h == 1) {
			System.out.println(1);
			System.exit(0);
		}

		do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1);

		sum += i;

		System.out.println(sum);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long sum = 0;
		long i = 1;

		if(h == 1) {
			System.out.println(1);
			System.exit(0);
		}

		do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1);

		sum += i;

		System.out.println(sum);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long sum = 0;
		long i = 1;

		if(h == 1) {
			System.out.println(1);
			System.exit(0);
		}

		do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1);

		sum += i;

		System.out.println(sum);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long sum = 0; sum 0 long i = 1; i 1 if(h == 1) {
			System.out.println(1);
			System.exit(0);
		} h == 1 h 1 {
			System.out.println(1);
			System.exit(0);
		} System.out.println(1) System.out.println System.out System System.out 1 System.exit(0) System.exit System 0 do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1); h > 1 h 1 {
			h /= 2;
			sum += i;
			i *= 2;
		} h /= 2 h 2 sum += i sum i i *= 2 i 2 sum += i sum i System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long sum = 0;
		long i = 1;

		if(h == 1) {
			System.out.println(1);
			System.exit(0);
		}

		do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1);

		sum += i;

		System.out.println(sum);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long sum = 0;
		long i = 1;

		if(h == 1) {
			System.out.println(1);
			System.exit(0);
		}

		do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1);

		sum += i;

		System.out.println(sum);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long sum = 0;
		long i = 1;

		if(h == 1) {
			System.out.println(1);
			System.exit(0);
		}

		do {
			h /= 2;
			sum += i;
			i *= 2;
		}while(h > 1);

		sum += i;

		System.out.println(sum);
		sc.close();
	}
}
