N = int(input()) ans = N%3 if ans==0: print(0) elif ans==1: print(2) else: print(1)