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

import java.util.*;
public class test4
{
    public static void main(String ar[])
    {
        long i;
        Scanner sc=new Scanner(System.in);
        i=sc.nextLong();
        int n=1378;
        long r1=1;
        if(i==0)
            r1=1;
            else
        for(int k=1;k<=i;k++)
        r1=r1*n;
        r1=r1%10;
        System.out.println(r1);
    }
}