# coding utf-8 ans = [2,8,5,7,1,4] N = int(input()) N = int(N % 6) print(ans[N])