import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    }
} Main public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    } main {
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long count =0; count 0 if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      } H==1 H 1 {
        System.out.println(1);
      } System.out.println(1) System.out.println System.out System System.out 1 {
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      } while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      } true {
        H/=2;
        count++;
        if(H==1){
          break;
        }
      } H/=2 H 2 count++ count if(H==1){
          break;
        } H==1 H 1 {
          break;
        } break; long ans =1+2*((long)Math.pow(2,count)-1); ans 1+2*((long)Math.pow(2,count)-1) 1 2*((long)Math.pow(2,count)-1) 2 ((long)Math.pow(2,count)-1) (long)Math.pow(2,count) Math.pow Math 2 count 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    }
} public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    }
}