import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  }
} Main public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  } main {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long H = scan.nextLong(); H scan.nextLong() scan.nextLong scan scan.close() scan.close scan long n = 1; n 1 while(H>>n > 0) {
      n++;
    } H>>n > 0 H>>n H n 0 {
      n++;
    } n++ n System.out.println(((long)1<<n) - 1) System.out.println System.out System System.out ((long)1<<n) - 1 ((long)1<<n) (long)1 n 1 String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  }
}