import java.util.Scanner;

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