#include <bits/stdc++.h>
int main()
{
    uint32_t seed;
    uint64_t inf = 0U, sup = ~0U;
    std::cin >> seed;
    constexpr uint32_t HALF = 5000001, ALL = 2 * HALF - 1;
    auto ok = [&](const uint64_t m) {
        uint32_t x = seed, y = 1, z = 2, w = 3, l = 0, e = 0, u = 0;
        auto gen = [&]() { const uint32_t t = (x ^ (x << 11)); return x=y,y=z,z=w,w=(w^(w>>19))^(t^(t>>8)); };
        for (uint32_t i = 0, v; i < ALL; i++) {
            v = gen(), (v < m ? l : v == m ? e : u)++;
            if (l >= HALF) { return 1; }
            if (u >= HALF) { return -1; }
        }
        return 0;
    };
    while (true) {
        const uint64_t mid = (sup + inf) / 2;
        if (ok(mid) == 0) { return std::cout << mid << std::endl, 0; }
        (ok(mid) == -1 ? inf : sup) = mid;
    }
}