fun main(args: Array<String>) {
    var H = readLine()!!.toLong()

    var counter = 0
    while (H > 0) {
        H /= 2
        counter++
    }


    var ans = 1L
    var base = 2L
    repeat(counter - 1) {
        ans += base
        base *= 2
    }
    println(ans)

}

