import java.util.Scanner;
 
public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	}
	
	public static long at(long H, long count) {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	}
	
	public static long at(long H, long count) {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	}
} Main public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	} main {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long H = Long.parseLong(scan.next()); H Long.parseLong(scan.next()) Long.parseLong Long scan.next() scan.next scan long num = at(H, 1); num at(H, 1) at H 1 long result = (long) Math.pow(2, num) - 1; result (long) Math.pow(2, num) - 1 (long) Math.pow(2, num) Math.pow Math 2 num 1 System.out.println(result) System.out.println System.out System System.out result String args[] args public static long at(long H, long count) {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	} at {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	} if(H == 1) {
			return count;
		} H == 1 H 1 {
			return count;
		} return count; count return at(H/2, count + 1); at(H/2, count + 1) at H/2 H 2 count + 1 count 1 long H H long count count public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	}
	
	public static long at(long H, long count) {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	}
} public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	}
	
	public static long at(long H, long count) {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	}
} Main
import java.util.Scanner;
 
public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	}
	
	public static long at(long H, long count) {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	}
}