import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    
    long multiple = 1;
    for(long i=h; i>0; i/=2) {
      multiple *= 2;
    }
    
    System.out.println(multiple-1);
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    
    long multiple = 1;
    for(long i=h; i>0; i/=2) {
      multiple *= 2;
    }
    
    System.out.println(multiple-1);
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    
    long multiple = 1;
    for(long i=h; i>0; i/=2) {
      multiple *= 2;
    }
    
    System.out.println(multiple-1);
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    
    long multiple = 1;
    for(long i=h; i>0; i/=2) {
      multiple *= 2;
    }
    
    System.out.println(multiple-1);
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) long h = Long.parseLong(in.readLine()); h Long.parseLong(in.readLine()) Long.parseLong Long in.readLine() in.readLine in long multiple = 1; multiple 1 for(long i=h; i>0; i/=2) {
      multiple *= 2;
    } long i=h; long i=h; i h i>0 i 0 i/=2 i/=2 i 2 {
      multiple *= 2;
    } {
      multiple *= 2;
    } multiple *= 2 multiple 2 System.out.println(multiple-1) System.out.println System.out System System.out multiple-1 multiple 1 String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    
    long multiple = 1;
    for(long i=h; i>0; i/=2) {
      multiple *= 2;
    }
    
    System.out.println(multiple-1);
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    
    long multiple = 1;
    for(long i=h; i>0; i/=2) {
      multiple *= 2;
    }
    
    System.out.println(multiple-1);
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    
    long multiple = 1;
    for(long i=h; i>0; i/=2) {
      multiple *= 2;
    }
    
    System.out.println(multiple-1);
  }
}