a=[int(i) for i in '428571'] print(a[int(input())%6])