import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        long H = Long.parseLong(br.readLine());
        long result = culcurate(H);
        
        System.out.println(result);
      }
    }

    public static long culcurate(long h){
      if(h == 1){
        return 1;
      }
      return 2*culcurate(h / 2) + 1;
    }
}  import java.util.*; util.* java import java.io.*; io.* java class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        long H = Long.parseLong(br.readLine());
        long result = culcurate(H);
        
        System.out.println(result);
      }
    }

    public static long culcurate(long h){
      if(h == 1){
        return 1;
      }
      return 2*culcurate(h / 2) + 1;
    }
} Main public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        long H = Long.parseLong(br.readLine());
        long result = culcurate(H);
        
        System.out.println(result);
      }
    } main {
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        long H = Long.parseLong(br.readLine());
        long result = culcurate(H);
        
        System.out.println(result);
      }
    } try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        long H = Long.parseLong(br.readLine());
        long result = culcurate(H);
        
        System.out.println(result);
      } {
        long H = Long.parseLong(br.readLine());
        long result = culcurate(H);
        
        System.out.println(result);
      } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) long H = Long.parseLong(br.readLine()); H Long.parseLong(br.readLine()) Long.parseLong Long br.readLine() br.readLine br long result = culcurate(H); result culcurate(H) culcurate H System.out.println(result) System.out.println System.out System System.out result String args[] args public static long culcurate(long h){
      if(h == 1){
        return 1;
      }
      return 2*culcurate(h / 2) + 1;
    } culcurate {
      if(h == 1){
        return 1;
      }
      return 2*culcurate(h / 2) + 1;
    } if(h == 1){
        return 1;
      } h == 1 h 1 {
        return 1;
      } return 1; 1 return 2*culcurate(h / 2) + 1; 2*culcurate(h / 2) + 1 2*culcurate(h / 2) 2 culcurate(h / 2) culcurate h / 2 h 2 1 long h h
import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        long H = Long.parseLong(br.readLine());
        long result = culcurate(H);
        
        System.out.println(result);
      }
    }

    public static long culcurate(long h){
      if(h == 1){
        return 1;
      }
      return 2*culcurate(h / 2) + 1;
    }
} 