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