
import java.util.Scanner;

public class Main {

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

		long h  = sc.nextLong();
		long ans = func(h);
		System.out.println(ans);

	}

	public static long func(long h) {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+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 ans = func(h);
		System.out.println(ans);

	}

	public static long func(long h) {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+1;
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		long ans = func(h);
		System.out.println(ans);

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

		long h  = sc.nextLong();
		long ans = func(h);
		System.out.println(ans);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h  = sc.nextLong(); h sc.nextLong() sc.nextLong sc long ans = func(h); ans func(h) func h System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static long func(long h) {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+1;
		}
	} func {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+1;
		}
	} if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+1;
		} h==1 h 1 {
			return 1;
		} return 1; 1 {
			return 2*func(h/2)+1;
		} return 2*func(h/2)+1; 2*func(h/2)+1 2*func(h/2) 2 func(h/2) func h/2 h 2 1 long h h public class Main {

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

		long h  = sc.nextLong();
		long ans = func(h);
		System.out.println(ans);

	}

	public static long func(long h) {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+1;
		}
	}
} public class Main {

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

		long h  = sc.nextLong();
		long ans = func(h);
		System.out.println(ans);

	}

	public static long func(long h) {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+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 ans = func(h);
		System.out.println(ans);

	}

	public static long func(long h) {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+1;
		}
	}
}