object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val monsterHP = BigInt(sc.next())

    var ans = BigInt(1)

    while (ans <= monsterHP) {
      ans *= 2
    }

    println(s"${ans - 1}")
  }
}
