fun main(args: Array<String>) {

        val h = readLine()!!.toLong()

        var n: Long = 1
        var count: Long = 1
        
        while (n*2 <= h) {
            n *= 2
            count = 2 * count + 1
        }
        
        print(count.toString())
}
