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());
    h = calc(h);
    System.out.println(h);
  }
  
  public static long calc(long h) {
    long res = 1;
    if(h>1)
      res = 1 + 2 * calc(h/2);
    return res;
  }
} 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());
    h = calc(h);
    System.out.println(h);
  }
  
  public static long calc(long h) {
    long res = 1;
    if(h>1)
      res = 1 + 2 * calc(h/2);
    return res;
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    h = calc(h);
    System.out.println(h);
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long h = Long.parseLong(in.readLine());
    h = calc(h);
    System.out.println(h);
  } 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 h = calc(h) h calc(h) calc h System.out.println(h) System.out.println System.out System System.out h String[] args args public static long calc(long h) {
    long res = 1;
    if(h>1)
      res = 1 + 2 * calc(h/2);
    return res;
  } calc {
    long res = 1;
    if(h>1)
      res = 1 + 2 * calc(h/2);
    return res;
  } long res = 1; res 1 if(h>1)
      res = 1 + 2 * calc(h/2); h>1 h 1 res = 1 + 2 * calc(h/2) res 1 + 2 * calc(h/2) 1 2 * calc(h/2) 2 calc(h/2) calc h/2 h 2 return res; res long h h 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());
    h = calc(h);
    System.out.println(h);
  }
  
  public static long calc(long h) {
    long res = 1;
    if(h>1)
      res = 1 + 2 * calc(h/2);
    return res;
  }
} 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());
    h = calc(h);
    System.out.println(h);
  }
  
  public static long calc(long h) {
    long res = 1;
    if(h>1)
      res = 1 + 2 * calc(h/2);
    return res;
  }
} 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());
    h = calc(h);
    System.out.println(h);
  }
  
  public static long calc(long h) {
    long res = 1;
    if(h>1)
      res = 1 + 2 * calc(h/2);
    return res;
  }
}