#include using ll = std::int64_t; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); ll N; std::cin >> N; ll res = (1ll << __builtin_popcountll(N)) - 2; std::cout << res << std::endl; }