import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		h = calc(h);
		System.out.println(h);
	}
	public static long calc(long h){
		long res = 1;
		if(h > 1){
			res = 1 + 2 * calc(h / 2);
		}
		return res;
	}
} 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();
		h = calc(h);
		System.out.println(h);
	}
	public static long calc(long h){
		long res = 1;
		if(h > 1){
			res = 1 + 2 * calc(h / 2);
		}
		return res;
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		h = calc(h);
		System.out.println(h);
	} main {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		h = calc(h);
		System.out.println(h);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc h = calc(h) h calc(h) calc h System.out.println(h) System.out.println System.out System System.out h String[] args args public static long calc(long h){
		long res = 1;
		if(h > 1){
			res = 1 + 2 * calc(h / 2);
		}
		return res;
	} calc {
		long res = 1;
		if(h > 1){
			res = 1 + 2 * calc(h / 2);
		}
		return res;
	} long res = 1; res 1 if(h > 1){
			res = 1 + 2 * calc(h / 2);
		} h > 1 h 1 {
			res = 1 + 2 * calc(h / 2);
		} res = 1 + 2 * calc(h / 2) res 1 + 2 * calc(h / 2) 1 2 * calc(h / 2) 2 calc(h / 2) calc h / 2 h 2 return res; res long h h public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		h = calc(h);
		System.out.println(h);
	}
	public static long calc(long h){
		long res = 1;
		if(h > 1){
			res = 1 + 2 * calc(h / 2);
		}
		return res;
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		h = calc(h);
		System.out.println(h);
	}
	public static long calc(long h){
		long res = 1;
		if(h > 1){
			res = 1 + 2 * calc(h / 2);
		}
		return res;
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		h = calc(h);
		System.out.println(h);
	}
	public static long calc(long h){
		long res = 1;
		if(h > 1){
			res = 1 + 2 * calc(h / 2);
		}
		return res;
	}
}