'use strict'

function Main(input) {
  input = input.trim()
  const H = parseInt(input)

  let cc = 1
  const dfs = (n) => {
    if(n === 1) return
    const h = Math.floor(n/2)
    cc++
    dfs(h)
  }
  dfs(H)
  console.log(Math.pow(2, cc) - 1)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));