def Main(): a,b=map(int,input().split()) k=a%4 for i in range(3): if 4*i+k not in (a,b): print(4*i+k) return Main()