"use strict";
function main(input) {
  const h = parseInt(input[0]);
  let two = [1];

  let i=1;
  while(true){
    let a = two[i-1]*2;
    if(a<10000000000000){
      two[i] = a;
      i++;
    }else{
      break;
    }
  }
  for(let i=0;i<two.length;i++){
    if(h<two[i]){
      console.log(two[i]-1);
      break;
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));