import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		long cnt = 0;
		while(h > 0) {
			h = h / 2;
			cnt++;
		}

		long ans = 0;

		long i;
		for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		long cnt = 0;
		while(h > 0) {
			h = h / 2;
			cnt++;
		}

		long ans = 0;

		long i;
		for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		long cnt = 0;
		while(h > 0) {
			h = h / 2;
			cnt++;
		}

		long ans = 0;

		long i;
		for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		long cnt = 0;
		while(h > 0) {
			h = h / 2;
			cnt++;
		}

		long ans = 0;

		long i;
		for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long h = scan.nextLong(); h scan.nextLong() scan.nextLong scan long cnt = 0; cnt 0 while(h > 0) {
			h = h / 2;
			cnt++;
		} h > 0 h 0 {
			h = h / 2;
			cnt++;
		} h = h / 2 h h / 2 h 2 cnt++ cnt long ans = 0; ans 0 long i; i for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		} i = 0; i = 0 i 0 i < cnt i cnt i++ i++ i {
			ans += Math.pow(2, i);
		} {
			ans += Math.pow(2, i);
		} ans += Math.pow(2, i) ans Math.pow(2, i) Math.pow Math 2 i 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 scan = new Scanner(System.in);
		long h = scan.nextLong();
		long cnt = 0;
		while(h > 0) {
			h = h / 2;
			cnt++;
		}

		long ans = 0;

		long i;
		for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println(ans);
	}
} public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		long cnt = 0;
		while(h > 0) {
			h = h / 2;
			cnt++;
		}

		long ans = 0;

		long i;
		for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		long cnt = 0;
		while(h > 0) {
			h = h / 2;
			cnt++;
		}

		long ans = 0;

		long i;
		for(i = 0; i < cnt; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println(ans);
	}
}