x=input().split() x=[int(i)for i in x] n=x[0]%4 for i in range(3): if not(i*4+n in x): print(i*4+n) break