# -*- coding: utf-8 -*- n = int(input()) cand = [2,8,5,7,1,4] print(cand[n%6-1])