import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static long H = scan.nextLong();
	static long min = 0;
	//static long []memo = new long[H+1];
	//static boolean []check = new boolean[H+1];
	static Set<Long> memo = new HashSet<Long>();
	static Map<Long,Long> me = new HashMap<Long,Long>();
	static ArrayList<Long> meno = new ArrayList<Long>();
	static Set<Boolean> cheak = new HashSet<Boolean>();
	
	public static void main(String[]args) {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	}

	private static long monster(long h) {
		
		
		if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		}
		}
} import java.util.ArrayList; ArrayList java.util import java.util.HashMap; HashMap java.util import java.util.HashSet; HashSet java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {
	static Scanner scan = new Scanner(System.in);
	static long H = scan.nextLong();
	static long min = 0;
	//static long []memo = new long[H+1];
	//static boolean []check = new boolean[H+1];
	static Set<Long> memo = new HashSet<Long>();
	static Map<Long,Long> me = new HashMap<Long,Long>();
	static ArrayList<Long> meno = new ArrayList<Long>();
	static Set<Boolean> cheak = new HashSet<Boolean>();
	
	public static void main(String[]args) {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	}

	private static long monster(long h) {
		
		
		if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		}
		}
} Main static Scanner scan = new Scanner(System.in); scan new Scanner(System.in) static long H = scan.nextLong(); H scan.nextLong() scan.nextLong scan static long min = 0; min 0 //static long []memo = new long[H+1];
	//static boolean []check = new boolean[H+1];
	static Set<Long> memo = new HashSet<Long>(); memo new HashSet<Long>() static Map<Long,Long> me = new HashMap<Long,Long>(); me new HashMap<Long,Long>() static ArrayList<Long> meno = new ArrayList<Long>(); meno new ArrayList<Long>() static Set<Boolean> cheak = new HashSet<Boolean>(); cheak new HashSet<Boolean>() public static void main(String[]args) {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	} main {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	} System.out.println(monster(H)) System.out.println System.out System System.out monster(H) monster H String[]args args private static long monster(long h) {
		
		
		if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		}
		} monster {
		
		
		if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		}
		} if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		} h==1 h 1 {
			
			return 1;	
		} return 1; 1 {
			long k = h/2;
			return 1+2*monster(k);
			
			
		} long k = h/2; k h/2 h 2 return 1+2*monster(k); 1+2*monster(k) 1 2*monster(k) 2 monster(k) monster k long h h public class Main {
	static Scanner scan = new Scanner(System.in);
	static long H = scan.nextLong();
	static long min = 0;
	//static long []memo = new long[H+1];
	//static boolean []check = new boolean[H+1];
	static Set<Long> memo = new HashSet<Long>();
	static Map<Long,Long> me = new HashMap<Long,Long>();
	static ArrayList<Long> meno = new ArrayList<Long>();
	static Set<Boolean> cheak = new HashSet<Boolean>();
	
	public static void main(String[]args) {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	}

	private static long monster(long h) {
		
		
		if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		}
		}
} public class Main {
	static Scanner scan = new Scanner(System.in);
	static long H = scan.nextLong();
	static long min = 0;
	//static long []memo = new long[H+1];
	//static boolean []check = new boolean[H+1];
	static Set<Long> memo = new HashSet<Long>();
	static Map<Long,Long> me = new HashMap<Long,Long>();
	static ArrayList<Long> meno = new ArrayList<Long>();
	static Set<Boolean> cheak = new HashSet<Boolean>();
	
	public static void main(String[]args) {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	}

	private static long monster(long h) {
		
		
		if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		}
		}
} Main
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static long H = scan.nextLong();
	static long min = 0;
	//static long []memo = new long[H+1];
	//static boolean []check = new boolean[H+1];
	static Set<Long> memo = new HashSet<Long>();
	static Map<Long,Long> me = new HashMap<Long,Long>();
	static ArrayList<Long> meno = new ArrayList<Long>();
	static Set<Boolean> cheak = new HashSet<Boolean>();
	
	public static void main(String[]args) {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	}

	private static long monster(long h) {
		
		
		if(h==1) {
			
			return 1;	
		}else {
			long k = h/2;
			return 1+2*monster(k);
			
			
		}
		}
}