import java.util.*;
public class Main {
  
  public static double cal(double h){
    if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    }
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	double h = sc.nextDouble();
    System.out.println(String.format("%.0f", cal(h)));
  }
} import java.util.*; util.* java public class Main {
  
  public static double cal(double h){
    if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    }
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	double h = sc.nextDouble();
    System.out.println(String.format("%.0f", cal(h)));
  }
} Main public static double cal(double h){
    if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    }
  } cal {
    if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    }
  } if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    } h == 1.0 h 1.0 {
      return 1.0;
    } return 1.0; 1.0 {
      return cal(Math.floor(h/2))*2 + 1.0;
    } return cal(Math.floor(h/2))*2 + 1.0; cal(Math.floor(h/2))*2 + 1.0 cal(Math.floor(h/2))*2 cal(Math.floor(h/2)) cal Math.floor(h/2) Math.floor Math h/2 h 2 2 1.0 double h h public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	double h = sc.nextDouble();
    System.out.println(String.format("%.0f", cal(h)));
  } main {
    Scanner sc = new Scanner(System.in);
	double h = sc.nextDouble();
    System.out.println(String.format("%.0f", cal(h)));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc System.out.println(String.format("%.0f", cal(h))) System.out.println System.out System System.out String.format("%.0f", cal(h)) String.format String "%.0f" cal(h) cal h String[] args args public class Main {
  
  public static double cal(double h){
    if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    }
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	double h = sc.nextDouble();
    System.out.println(String.format("%.0f", cal(h)));
  }
} public class Main {
  
  public static double cal(double h){
    if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    }
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	double h = sc.nextDouble();
    System.out.println(String.format("%.0f", cal(h)));
  }
} Main
import java.util.*;
public class Main {
  
  public static double cal(double h){
    if(h == 1.0){
      return 1.0;
    }
    else
    {
      return cal(Math.floor(h/2))*2 + 1.0;
    }
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	double h = sc.nextDouble();
    System.out.println(String.format("%.0f", cal(h)));
  }
}