package yukicoder; import java.util.Arrays; import java.util.Scanner; public class No702 { Scanner in; String INPUT = ""; void solve() { int seed = ni(); long low = 0, high = 1L<<32; while(high - low > 1){ long h = high+low>>1; x = seed; y = 1; z = 2; w = 3; int bal = 0; for(int i = 0;i < 10000001;i++){ long v = generate(); if(v <= h){ bal--; }else{ bal++; } } if(bal < 0){ high = h; }else{ low = h; } } System.out.println(high); } long x = 0, y = 1, z = 2, w = 3; long generate() { long t = (x^(x<<11))&(1L<<32)-1; x = y; y = z; z = w; w = ((w ^ (w >> 19)) ^ (t ^ (t >> 8))) & (1L<<32)-1; return w; } void run() throws Exception { in = oj ? new Scanner(System.in) : new Scanner(INPUT); long s = System.currentTimeMillis(); solve(); tr(System.currentTimeMillis()-s+"ms"); } public static void main(String[] args) throws Exception { new No702().run(); } int ni() { return Integer.parseInt(in.next()); } long nl() { return Long.parseLong(in.next()); } double nd() { return Double.parseDouble(in.next()); } boolean oj = System.getProperty("ONLINE_JUDGE") != null; void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); } }