a, b = map(int, input().split())


"""
10**12 < 2**40
任意の整数について、n ^ (n+1) = 1
"""
def f(n):
    if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n

print(f(a-1)^f(b)) a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b """
10**12 < 2**40
任意の整数について、n ^ (n+1) = 1
""" def f(n):
    if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n f if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n n%2!=0 n%2 n 2 0 if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
     ((n+1)//2)%2!=0 ((n+1)//2)%2 (n+1)//2 n+1 n 1 2 2 0 return 1 1 return 0 0 if (n//2)%2!=0:
            return n ^ 1
        else:
            return n (n//2)%2!=0 (n//2)%2 n//2 n 2 2 0 return n ^ 1 n ^ 1 n 1 return n n n n print(f(a-1)^f(b)) print f(a-1)^f(b) f(a-1) f a-1 a 1 f(b) f b def f(n):
    if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n def f(n):
    if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n f a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b
a, b = map(int, input().split())


"""
10**12 < 2**40
任意の整数について、n ^ (n+1) = 1
"""
def f(n):
    if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n

print(f(a-1)^f(b))