import java.text.*
fun main(a: Array<String>) {
  val v = readLine()!!.toDouble()
  println(DecimalFormat("#################").format((2.0.pow(floor(log2(v) + 1)) - 1)))
}

fun log2(d: Double) = Math.log(d)/Math.log(2.0)
fun Double.pow(a: Double) = Math.pow(this, a)
fun floor(d: Double) = Math.floor(d)