import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long count = 0;
    while (true) {
      if (Math.pow(2,count) > H) break;
      count++;
    }
    System.out.println((long)Math.pow(2,count) -1);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long count = 0;
    while (true) {
      if (Math.pow(2,count) > H) break;
      count++;
    }
    System.out.println((long)Math.pow(2,count) -1);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long count = 0;
    while (true) {
      if (Math.pow(2,count) > H) break;
      count++;
    }
    System.out.println((long)Math.pow(2,count) -1);
  } main {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long count = 0;
    while (true) {
      if (Math.pow(2,count) > H) break;
      count++;
    }
    System.out.println((long)Math.pow(2,count) -1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long count = 0; count 0 while (true) {
      if (Math.pow(2,count) > H) break;
      count++;
    } true {
      if (Math.pow(2,count) > H) break;
      count++;
    } if (Math.pow(2,count) > H) break; Math.pow(2,count) > H Math.pow(2,count) Math.pow Math 2 count H break; count++ count System.out.println((long)Math.pow(2,count) -1) System.out.println System.out System System.out (long)Math.pow(2,count) -1 (long)Math.pow(2,count) Math.pow Math 2 count 1 String[] args args
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long count = 0;
    while (true) {
      if (Math.pow(2,count) > H) break;
      count++;
    }
    System.out.println((long)Math.pow(2,count) -1);
  }
}