/*
 * Click `Run` to execute the snippet below!
 */

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

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    System.out.println(ans);
  }
} import java.io.*; io.* java 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 ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    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 ans = 0; ans 0 long k = 1; k 1 while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    } H >= 1 H 1 {
      ans += k;
      k *= 2;
      H /= 2;
    } ans += k ans k k *= 2 k 2 H /= 2 H 2 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 ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    System.out.println(ans);
  }
} public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    System.out.println(ans);
  }
} Main
/*
 * Click `Run` to execute the snippet below!
 */

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

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    System.out.println(ans);
  }
}