fun main(args:Array<String>) {
    var n = readLine()!!.toLong()
    var cnt = 0
    var result = 1L
    while (n > 0) {
        n /= 2
        ++cnt
        result *= 2
    }
    result -= 1L
    println(result)
}