import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    sc.close();

    long cnt = 0;
    long h = H;
    while (h != 1) {
      h /= 2;
      cnt++;
    }
    long ans = 1;
    for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    }
    System.out.println(ans);
  }
} import java.math.*; math.* java import java.util.*; util.* java import java.util.function.*; function.* java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    sc.close();

    long cnt = 0;
    long h = H;
    while (h != 1) {
      h /= 2;
      cnt++;
    }
    long ans = 1;
    for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    sc.close();

    long cnt = 0;
    long h = H;
    while (h != 1) {
      h /= 2;
      cnt++;
    }
    long ans = 1;
    for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    sc.close();

    long cnt = 0;
    long h = H;
    while (h != 1) {
      h /= 2;
      cnt++;
    }
    long ans = 1;
    for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    }
    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 sc.close() sc.close sc long cnt = 0; cnt 0 long h = H; h H while (h != 1) {
      h /= 2;
      cnt++;
    } h != 1 h 1 {
      h /= 2;
      cnt++;
    } h /= 2 h 2 cnt++ cnt long ans = 1; ans 1 for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    } int i = 1; int i = 1; i 1 i <= cnt i cnt i++ i++ i {
      ans += (long) Math.pow(2, i);
    } {
      ans += (long) Math.pow(2, i);
    } ans += (long) Math.pow(2, i) ans (long) Math.pow(2, i) Math.pow Math 2 i 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();
    sc.close();

    long cnt = 0;
    long h = H;
    while (h != 1) {
      h /= 2;
      cnt++;
    }
    long ans = 1;
    for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    sc.close();

    long cnt = 0;
    long h = H;
    while (h != 1) {
      h /= 2;
      cnt++;
    }
    long ans = 1;
    for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    }
    System.out.println(ans);
  }
} Main
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    sc.close();

    long cnt = 0;
    long h = H;
    while (h != 1) {
      h /= 2;
      cnt++;
    }
    long ans = 1;
    for (int i = 1; i <= cnt; i++) {
      ans += (long) Math.pow(2, i);
    }
    System.out.println(ans);
  }
}