import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	}
}

class Caracal {
	long attack(long h) {
		if (h > 1) return attack(h / 2) * 2 + 1;
		if (h == 1) return 1;
		return 0;
	}
} 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();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long h = scan.nextLong(); h scan.nextLong() scan.nextLong scan Caracal caracal = new Caracal(); caracal new Caracal() System.out.println(caracal.attack(h)) System.out.println System.out System System.out caracal.attack(h) caracal.attack caracal h scan.close() scan.close scan String[] args args class Caracal {
	long attack(long h) {
		if (h > 1) return attack(h / 2) * 2 + 1;
		if (h == 1) return 1;
		return 0;
	}
} Caracal long attack(long h) {
		if (h > 1) return attack(h / 2) * 2 + 1;
		if (h == 1) return 1;
		return 0;
	} attack {
		if (h > 1) return attack(h / 2) * 2 + 1;
		if (h == 1) return 1;
		return 0;
	} if (h > 1) return attack(h / 2) * 2 + 1; h > 1 h 1 return attack(h / 2) * 2 + 1; attack(h / 2) * 2 + 1 attack(h / 2) * 2 attack(h / 2) attack h / 2 h 2 2 1 if (h == 1) return 1; h == 1 h 1 return 1; 1 return 0; 0 long h h public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	}
}

class Caracal {
	long attack(long h) {
		if (h > 1) return attack(h / 2) * 2 + 1;
		if (h == 1) return 1;
		return 0;
	}
}
