import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long H = Long.parseLong(W);;

		long X=H;
		long n=1;
		while(X!=1){
			X=X/2;

			n++;
		}
		System.out.println((long)Math.pow(2,n)-1);
	}
} import java.io.*; io.* java public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long H = Long.parseLong(W);;

		long X=H;
		long n=1;
		while(X!=1){
			X=X/2;

			n++;
		}
		System.out.println((long)Math.pow(2,n)-1);
	}
} Main final static long MOD = 1000000007; MOD 1000000007 public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long H = Long.parseLong(W);;

		long X=H;
		long n=1;
		while(X!=1){
			X=X/2;

			n++;
		}
		System.out.println((long)Math.pow(2,n)-1);
	} main {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long H = Long.parseLong(W);;

		long X=H;
		long n=1;
		while(X!=1){
			X=X/2;

			n++;
		}
		System.out.println((long)Math.pow(2,n)-1);
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String W = in.readLine(); W in.readLine() in.readLine in long H = Long.parseLong(W); H Long.parseLong(W) Long.parseLong Long W long X=H; X H long n=1; n 1 while(X!=1){
			X=X/2;

			n++;
		} X!=1 X 1 {
			X=X/2;

			n++;
		} X=X/2 X X/2 X 2 n++ n System.out.println((long)Math.pow(2,n)-1) System.out.println System.out System System.out (long)Math.pow(2,n)-1 (long)Math.pow(2,n) Math.pow Math 2 n 1 String[] args args public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long H = Long.parseLong(W);;

		long X=H;
		long n=1;
		while(X!=1){
			X=X/2;

			n++;
		}
		System.out.println((long)Math.pow(2,n)-1);
	}
} public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long H = Long.parseLong(W);;

		long X=H;
		long n=1;
		while(X!=1){
			X=X/2;

			n++;
		}
		System.out.println((long)Math.pow(2,n)-1);
	}
} Main
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long H = Long.parseLong(W);;

		long X=H;
		long n=1;
		while(X!=1){
			X=X/2;

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