import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	} main {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) long H = stdIn.nextLong(); H stdIn.nextLong() stdIn.nextLong stdIn long n = 0; n 0 while(H>0) {
			H /= 2;
			n++;
		} H>0 H 0 {
			H /= 2;
			n++;
		} H /= 2 H 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 {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	}
}
