12
 1378
 51202278
 989898989
 4
 7
 9
 6
 8
 12193721
 999999995
 999999999
 11
 999999996
 999999998
 3
 14
 15
 10
 999999994
 1000
 13781378
 5
 999999997
 1000000000
 13
 16
 0

6
 4
 4
 8
 6
 2
 8
 4
 6
 8
 2
 2
 2
 6
 4
 2
 4
 2
 4
 4
 6
 4
 8
 8
 6
 8
 6
 1

# -*- coding: utf-8 -*-
"""
Created on Thu Aug 13 19:00:53 2020

@author: The Wonder Land
"""
"""
There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.

Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given n, print the last digit of 1378 n.


Mehrdad has become quite confused and wants you to help him. Please help, although it's a naive cheat.

Input
The single line of input contains one integer n (0  ≤  n  ≤  109).

Output
Print single integer — the last digit of 1378 n.

Examples
inputCopy
1
outputCopy
8
inputCopy
2
outputCopy
4
"""
n = int(input())
if n == 0:
    print("1")
    quit()
if n%4 == 1:
    print("8")
elif n%4 == 2:
    print("4")
elif n%4 == 3:
    print("2")
elif n%4 == 0:
    print("6")
    