import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	} try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		} {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc int cnt = 0; cnt 0 for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			} ; {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			} {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			} if (H == 1) {
					break;
				} H == 1 H 1 {
					break;
				} break; H = H / 2 H H / 2 H 2 cnt++ cnt long ans = 1; ans 1 for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
				ans = 2 * ans + 1;
			} {
				ans = 2 * ans + 1;
			} ans = 2 * ans + 1 ans 2 * ans + 1 2 * ans 2 ans 1 System.out.print(ans) System.out.print System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	}
} public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	}
}
