package yukicoder; import java.util.Scanner; public class No702 { static long x = 0, y = 1, z = 2, w = 3; static 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; } public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int seed = in.nextInt(); 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); } }