import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long H = scanner.nextLong();
    H = H / 2 * 2;
    long count = 1;
    while (H > 1) {
      H /= 2;
      count = count * 2 + 1;
    }
    System.out.println(count);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

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

    long H = scanner.nextLong();
    H = H / 2 * 2;
    long count = 1;
    while (H > 1) {
      H /= 2;
      count = count * 2 + 1;
    }
    System.out.println(count);
  } main {
    Scanner scanner = new Scanner(System.in);

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

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

    long H = scanner.nextLong();
    H = H / 2 * 2;
    long count = 1;
    while (H > 1) {
      H /= 2;
      count = count * 2 + 1;
    }
    System.out.println(count);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long H = scanner.nextLong();
    H = H / 2 * 2;
    long count = 1;
    while (H > 1) {
      H /= 2;
      count = count * 2 + 1;
    }
    System.out.println(count);
  }
}
