'use strict';
const main = input => {
  let h = parseInt(input[0]);
  const check = num => {
    let twoPow = 1;
    let sum = 0;
    let count = 0;
    while(sum<=num) {
      sum += twoPow;
      twoPow *= 2;
      count++;
    }
    return count;
  }
  let ans = Math.pow(2, check(h-1))-1;
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));
/*
1  1   2  1
2  3   4  2
3  7   8  3
4  7   8  3
5  15  16 4
6  15  16 4
7  15  16 4
8  15  16 4
9  31  32 5
10 31  32 5
11 31  32 5
12 31  32 5
13 31  32 5
14 31  32 5
15 31  32 5
16 31  32 5
17 63  64 6

1, 1, 2, 4, 8, 16, ...
*/