# -*- coding: utf-8 -*- from sys import stdin a = int(stdin.readline().rstrip()) junkan = "428571" keta = a%6 print(junkan[keta])