#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Xorshift
{
private:
    uint32_t x, y, z, w;
public:
    Xorshift(uint32_t seed){
        x = seed;
        y = 1;
        z = 2;
        w = 3;
    }
    uint32_t operator()(){
        uint32_t t=(x^(x<<11));
        x=y; y=z; z=w;
        return w=(w^(w>>19))^(t^(t>>8));
    }
};

const unsigned MID = 0x80000000;
const int LEN = 0x200000;

int main()
{
    int seed;
    cin >> seed;
    Xorshift xorshift(seed);

    int n = 10000001;
    vector<int> cnt(LEN*2+1);
    for(int i=0; i<n; ++i){
        long long a = xorshift();
        a -= MID;
        if(a < -LEN)
            a = -LEN;
        else if(a > LEN)
            a = LEN;
        ++ cnt[(unsigned)a+LEN];
    }

    int a = 0;
    int tmp = 0;
    for(;;){
        tmp += cnt[a];
        if(tmp > n / 2)
            break;
        ++ a;
    }

    long long ans = a;
    ans += MID - LEN;
    cout << ans << endl;

    return 0;
}