import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final long initialHitPoint = scanner.nextLong();

    System.out.println(getAttackCount(initialHitPoint));
  }

  private static long getAttackCount(long hitPoint) {
    if (hitPoint == 1) {
      return 1;
    }

    return getAttackCount(hitPoint / 2) * 2 + 1;
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final long initialHitPoint = scanner.nextLong();

    System.out.println(getAttackCount(initialHitPoint));
  }

  private static long getAttackCount(long hitPoint) {
    if (hitPoint == 1) {
      return 1;
    }

    return getAttackCount(hitPoint / 2) * 2 + 1;
  }
} Main public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final long initialHitPoint = scanner.nextLong();

    System.out.println(getAttackCount(initialHitPoint));
  } main {
    final Scanner scanner = new Scanner(System.in);
    final long initialHitPoint = scanner.nextLong();

    System.out.println(getAttackCount(initialHitPoint));
  } final Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) final long initialHitPoint = scanner.nextLong(); initialHitPoint scanner.nextLong() scanner.nextLong scanner System.out.println(getAttackCount(initialHitPoint)) System.out.println System.out System System.out getAttackCount(initialHitPoint) getAttackCount initialHitPoint String[] args args private static long getAttackCount(long hitPoint) {
    if (hitPoint == 1) {
      return 1;
    }

    return getAttackCount(hitPoint / 2) * 2 + 1;
  } getAttackCount {
    if (hitPoint == 1) {
      return 1;
    }

    return getAttackCount(hitPoint / 2) * 2 + 1;
  } if (hitPoint == 1) {
      return 1;
    } hitPoint == 1 hitPoint 1 {
      return 1;
    } return 1; 1 return getAttackCount(hitPoint / 2) * 2 + 1; getAttackCount(hitPoint / 2) * 2 + 1 getAttackCount(hitPoint / 2) * 2 getAttackCount(hitPoint / 2) getAttackCount hitPoint / 2 hitPoint 2 2 1 long hitPoint hitPoint public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final long initialHitPoint = scanner.nextLong();

    System.out.println(getAttackCount(initialHitPoint));
  }

  private static long getAttackCount(long hitPoint) {
    if (hitPoint == 1) {
      return 1;
    }

    return getAttackCount(hitPoint / 2) * 2 + 1;
  }
} public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final long initialHitPoint = scanner.nextLong();

    System.out.println(getAttackCount(initialHitPoint));
  }

  private static long getAttackCount(long hitPoint) {
    if (hitPoint == 1) {
      return 1;
    }

    return getAttackCount(hitPoint / 2) * 2 + 1;
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final long initialHitPoint = scanner.nextLong();

    System.out.println(getAttackCount(initialHitPoint));
  }

  private static long getAttackCount(long hitPoint) {
    if (hitPoint == 1) {
      return 1;
    }

    return getAttackCount(hitPoint / 2) * 2 + 1;
  }
}