
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		sc.close();
		long num = 1;
		while(h > 1) {
			h = h/2;
			num+=1;
		}
		System.out.println((long)(Math.pow(2, num)-1));
		
	}

} 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();
		sc.close();
		long num = 1;
		while(h > 1) {
			h = h/2;
			num+=1;
		}
		System.out.println((long)(Math.pow(2, num)-1));
		
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		sc.close();
		long num = 1;
		while(h > 1) {
			h = h/2;
			num+=1;
		}
		System.out.println((long)(Math.pow(2, num)-1));
		
	} main {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		sc.close();
		long num = 1;
		while(h > 1) {
			h = h/2;
			num+=1;
		}
		System.out.println((long)(Math.pow(2, num)-1));
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h  = sc.nextLong(); h sc.nextLong() sc.nextLong sc sc.close() sc.close sc long num = 1; num 1 while(h > 1) {
			h = h/2;
			num+=1;
		} h > 1 h 1 {
			h = h/2;
			num+=1;
		} h = h/2 h h/2 h 2 num+=1 num 1 System.out.println((long)(Math.pow(2, num)-1)) System.out.println System.out System System.out (long)(Math.pow(2, num)-1) Math.pow(2, num) Math.pow Math 2 num 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		sc.close();
		long num = 1;
		while(h > 1) {
			h = h/2;
			num+=1;
		}
		System.out.println((long)(Math.pow(2, num)-1));
		
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		sc.close();
		long num = 1;
		while(h > 1) {
			h = h/2;
			num+=1;
		}
		System.out.println((long)(Math.pow(2, num)-1));
		
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		sc.close();
		long num = 1;
		while(h > 1) {
			h = h/2;
			num+=1;
		}
		System.out.println((long)(Math.pow(2, num)-1));
		
	}

}