import java.util.Scanner;

public class Main {
	
	static int count = 1;

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long h = Long.parseLong(scan.nextLine());
		
		test(h);
		System.out.println((long) Math.pow(2, count) - 1);
	}
	
	public static void test(long hp) {
		hp = hp / 2;
		if (hp == 0) return; 
		count++;
		test(hp);
	}
	
} import java.util.Scanner; Scanner java.util public class Main {
	
	static int count = 1;

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long h = Long.parseLong(scan.nextLine());
		
		test(h);
		System.out.println((long) Math.pow(2, count) - 1);
	}
	
	public static void test(long hp) {
		hp = hp / 2;
		if (hp == 0) return; 
		count++;
		test(hp);
	}
	
} Main static int count = 1; count 1 public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long h = Long.parseLong(scan.nextLine());
		
		test(h);
		System.out.println((long) Math.pow(2, count) - 1);
	} main {
		
		Scanner scan = new Scanner(System.in);
		long h = Long.parseLong(scan.nextLine());
		
		test(h);
		System.out.println((long) Math.pow(2, count) - 1);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long h = Long.parseLong(scan.nextLine()); h Long.parseLong(scan.nextLine()) Long.parseLong Long scan.nextLine() scan.nextLine scan test(h) test h System.out.println((long) Math.pow(2, count) - 1) System.out.println System.out System System.out (long) Math.pow(2, count) - 1 (long) Math.pow(2, count) Math.pow Math 2 count 1 String[] args args public static void test(long hp) {
		hp = hp / 2;
		if (hp == 0) return; 
		count++;
		test(hp);
	} test {
		hp = hp / 2;
		if (hp == 0) return; 
		count++;
		test(hp);
	} hp = hp / 2 hp hp / 2 hp 2 if (hp == 0) return; hp == 0 hp 0 return; count++ count test(hp) test hp long hp hp public class Main {
	
	static int count = 1;

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long h = Long.parseLong(scan.nextLine());
		
		test(h);
		System.out.println((long) Math.pow(2, count) - 1);
	}
	
	public static void test(long hp) {
		hp = hp / 2;
		if (hp == 0) return; 
		count++;
		test(hp);
	}
	
} public class Main {
	
	static int count = 1;

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long h = Long.parseLong(scan.nextLine());
		
		test(h);
		System.out.println((long) Math.pow(2, count) - 1);
	}
	
	public static void test(long hp) {
		hp = hp / 2;
		if (hp == 0) return; 
		count++;
		test(hp);
	}
	
} Main
import java.util.Scanner;

public class Main {
	
	static int count = 1;

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long h = Long.parseLong(scan.nextLine());
		
		test(h);
		System.out.println((long) Math.pow(2, count) - 1);
	}
	
	public static void test(long hp) {
		hp = hp / 2;
		if (hp == 0) return; 
		count++;
		test(hp);
	}
	
}