public class Euler877 {

    static long xFast(long n) {
        long x = 0;
        long a = 0;
        long b = 3;
        while (b <= n && b >= 0) { // handling potential sign bit overflow, though 10^18 won't overflow
            x ^= b;
            long nextVal = (b << 1) ^ a;
            a = b;
            b = nextVal;
        }
        return x;
    }

    public static String solve() {
        return Long.toString(xFast(1000000000000000000L));
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
