n = int(input()) r = n % 3 if r == 0: print(0) elif r == 1: print(2) else: print(1)