import java.util.*;
import java.math.*;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong()/2;


    long count = 1;
    long k = 1;
    while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    }

    System.out.println(count);


  }

} import java.util.*; util.* java import java.math.*; math.* java import java.util.Arrays; Arrays java.util public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong()/2;


    long count = 1;
    long k = 1;
    while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    }

    System.out.println(count);


  }

} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong()/2;


    long count = 1;
    long k = 1;
    while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    }

    System.out.println(count);


  } main {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong()/2;


    long count = 1;
    long k = 1;
    while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    }

    System.out.println(count);


  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong()/2; h sc.nextLong()/2 sc.nextLong() sc.nextLong sc 2 long count = 1; count 1 long k = 1; k 1 while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    } h > 0 h 0 {
      k *= 2;
      count += k;
      h /= 2;
    } k *= 2 k 2 count += k count k h /= 2 h 2 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 sc = new Scanner(System.in);
    long h = sc.nextLong()/2;


    long count = 1;
    long k = 1;
    while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    }

    System.out.println(count);


  }

} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong()/2;


    long count = 1;
    long k = 1;
    while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    }

    System.out.println(count);


  }

} Main
import java.util.*;
import java.math.*;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong()/2;


    long count = 1;
    long k = 1;
    while (h > 0) {
      k *= 2;
      count += k;
      h /= 2;
    }

    System.out.println(count);


  }

}
