"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
let h = +input[0];
let cnt = 0;
while (h > 0) {
    h = Math.floor(h / 2);
    cnt++;
}
console.log(Math.pow(2, cnt) - 1);
