import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    long n = input.nextLong();
    long ans = 1;
    while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    }
    System.out.print(ans - 1);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    long n = input.nextLong();
    long ans = 1;
    while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    }
    System.out.print(ans - 1);
  }
} Main public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    long n = input.nextLong();
    long ans = 1;
    while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    }
    System.out.print(ans - 1);
  } main {
    Scanner input = new Scanner(System.in);
    long n = input.nextLong();
    long ans = 1;
    while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    }
    System.out.print(ans - 1);
  } Scanner input = new Scanner(System.in); input new Scanner(System.in) long n = input.nextLong(); n input.nextLong() input.nextLong input long ans = 1; ans 1 while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    } n > 0 n 0 {
      ans = ans * 2;
      n = n / 2;
    } ans = ans * 2 ans ans * 2 ans 2 n = n / 2 n n / 2 n 2 System.out.print(ans - 1) System.out.print System.out System System.out ans - 1 ans 1 String[] args args public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    long n = input.nextLong();
    long ans = 1;
    while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    }
    System.out.print(ans - 1);
  }
} public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    long n = input.nextLong();
    long ans = 1;
    while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    }
    System.out.print(ans - 1);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    long n = input.nextLong();
    long ans = 1;
    while (n > 0) {
      ans = ans * 2;
      n = n / 2;
    }
    System.out.print(ans - 1);
  }
}
