
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		   Scanner sc = new Scanner(System.in);
		    long H = sc.nextLong();
		    long Attack = 0;
		    long Monster = 1;
		    
		    while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    }
		 
		    System.out.println(Attack);
		sc.close();
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		   Scanner sc = new Scanner(System.in);
		    long H = sc.nextLong();
		    long Attack = 0;
		    long Monster = 1;
		    
		    while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    }
		 
		    System.out.println(Attack);
		sc.close();
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		   Scanner sc = new Scanner(System.in);
		    long H = sc.nextLong();
		    long Attack = 0;
		    long Monster = 1;
		    
		    while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    }
		 
		    System.out.println(Attack);
		sc.close();
	} main {
		// TODO 自動生成されたメソッド・スタブ
		   Scanner sc = new Scanner(System.in);
		    long H = sc.nextLong();
		    long Attack = 0;
		    long Monster = 1;
		    
		    while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    }
		 
		    System.out.println(Attack);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long Attack = 0; Attack 0 long Monster = 1; Monster 1 while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    } H > 0 H 0 {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    } Attack += Monster Attack Monster H /= 2 H 2 Monster *= 2 Monster 2 System.out.println(Attack) System.out.println System.out System System.out Attack sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		   Scanner sc = new Scanner(System.in);
		    long H = sc.nextLong();
		    long Attack = 0;
		    long Monster = 1;
		    
		    while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    }
		 
		    System.out.println(Attack);
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		   Scanner sc = new Scanner(System.in);
		    long H = sc.nextLong();
		    long Attack = 0;
		    long Monster = 1;
		    
		    while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    }
		 
		    System.out.println(Attack);
		sc.close();
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		   Scanner sc = new Scanner(System.in);
		    long H = sc.nextLong();
		    long Attack = 0;
		    long Monster = 1;
		    
		    while (H > 0) {
		      Attack += Monster;
		      H /= 2;
		      Monster *= 2;
		    }
		 
		    System.out.println(Attack);
		sc.close();
	}

}