

import java.util.Scanner;

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

		long h = sc.nextLong();

		long count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

	}

} 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 count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

	}

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

		long h = sc.nextLong();

		long count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

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

		long h = sc.nextLong();

		long count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

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

		long h = sc.nextLong();

		long count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

	}

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

		long h = sc.nextLong();

		long count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

	}

} 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 count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

	}

}
