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 1378n. 

<image>

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 1378n.

Examples

Input

1


Output

8

Input

2


Output

4

Note

In the first example, last digit of 13781 = 1378 is 8.

In the second example, last digit of 13782 = 1378·1378 = 1898884 is 4.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.StringTokenizer;
 
//import dynamic_programming.FastReader;
 
public class Number_theory implements Runnable{
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static void main(String[] args) throws Exception {
	    new Thread(null, new Number_theory(), "Main", 1<<26).start();
	  }
	public void run() {
		OutputStream outputStream =System.out;
	    PrintWriter out =new PrintWriter(outputStream);
	FastReader s=new FastReader();
//    t=s.nextInt();
//	while(t>0) {
//		int n=s.nextInt();
//		int q=s.nextInt();
//		int[] a=new int[n+1];
//		int[] pref=new int[n+1];
//		int[] suff=new int[n+1];
//		for(int i=1;i<=n;i++) {
//			a[i]=s.nextInt();
//		}
//		pref[1]=a[1];
//		for(int i=2;i<=n;i++) {
//			pref[i]=(int) GCD(a[i],pref[i-1]);
//		}
//		suff[n]=a[n];
//		for(int i=n-1;i>=1;i--) {
//			suff[i]=(int) GCD(a[i],suff[i+1]);
//		}
//		while(q>0) {
//			int l=s.nextInt();
//			int r=s.nextInt();
//			long g1=0;
//			long g2=0;
//			if(l!=1) {
//				g1=pref[l-1];
//			}
//			if(r!=n) {
//				g2=suff[r+1];
//			}
//			if(g1==0) {
//				out.println(g2);
//			}else if(g2==0) {
//				out.println(g1);
//			}else {
//				out.println(GCD(g1,g2));
//			}
//			q--;
//		}
//	t--;
//	}
//	int n=s.nextInt();
	long n=s.nextLong();
	long v= binary_exponentiation_1(8,n);
	out.print(v%10);
	out.close();
	}
	int k=0;
	int t=0;
	public static boolean isPrime(long n) {
		if(n==(long)1 || n==(long)0) {
			return false;
		}
		for(long i=2;i*i<=n;i++) {
			if(n%i==0) {
				return false;
			}
		}
		return true;
	}
	public static long find_fibonacci(long a,long b,int n) {
		long ans=0;
		n++;
		long[][] mat=new long[2][2];
		if(n<=2) {
			if(n==1) {
				return a;
			}else {
				return b;
			}
		}else {
			n-=2;
			
			mat[0][1]=mat[1][1]=mat[1][0]=1;
			mat[0][0]=0;
			long[][] res=matrix_exponentiation(mat,2,(int)n);
			ans+=(a*res[0][1] +b*res[1][1])%(1000000007);
		}
		return ans;
	}
	public static  int[] arr=new int[1000001];
	public static int[] is_prime=new int[1000001];
	public static void sieve() {
		long maxN=1000000;
		for(int i=1;i<=maxN;i++) {
			is_prime[i]=1;
		}
		is_prime[0]=0;
		is_prime[1]=0;
		for(long i=2;i*i<=maxN;i++) {
			if(is_prime[(int) i]==1) {
				for(long j=i*i;j<=maxN;j+=i) {
					is_prime[(int) j]=0;
				}
			}
		}
		int count=0;
		for(long i=1;i<=maxN;i++) {
			if(is_prime[(int) i]==1) {
				count++;
			}
			if(is_prime[count]==1) {
				arr[(int) i]=1;
			}else {
				arr[(int)i]=0;
			}
		}
	}
	
	public static void seive_for_prime_factorization() {
		for(int i=2;i<=1000000;i++) {
			arr[i]=-1;
		}
		for(int i=2;i<=1000000;i++) {
			if(arr[i]==-1) {
				for(int j=i;j<=1000000;j+=i) {
					if(arr[j]==-1) {
					arr[j]=i;}
				}
			}
		}
	}
	public static void prime_factorization(long n) {
		for(long i=2;i*i<=n;i++) {
			if(n%i==0) {
				int count=0;
				while(n%i==0) {
					count++;
					n/=i;
				}
				System.out.println(i+" "+count);
			}
		}
		if(n>1) {
			System.out.println( n+" "+1);
		}
		
	}
	public static ArrayList<Integer> prime_vector=new ArrayList<>();
public static long binary_exponentiation(long a,long n) {
	long res=1;
	while(n>0) {
		if(n%2!=0) {
			res*=a;
			n--;
		}else {
			a*=a;
			n/=2;
		}
	}
	return res;
	
}
public static long binary_exponentiation_1(long a,long n) {
	long res=1;
	while(n>0) {
		if(n%2!=0) {
			res=(res*a)%10;
			n--;
		}else {
			a=(a*a)%(10);
			n/=2;
		}
	}
	return res;
	
}

public static long[][] matrix_exponentiation(long[][] mat,int n,int m){
	long[][] a=new long[n][n];
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(i==j) {
				a[i][j]=(long)1;
			}
		}
	}
	while(m>0) {
		if(m%2==0) {
			mat=mul(mat,mat,n);
			m/=2;
		}else {
			a=mul(a,mat,n);
			m--;
		}
	}
	return a;
}
public static long[][] mul(long[][] a,long[][] b,int n1){
	long[][] res=new long[n1][n1];
	for(int i=0;i<n1;i++) {
		for(int j=0;j<n1;j++) {
			for(int k=0;k<n1;k++) {
				long g=(a[i][k])*(b[k][j])%(1000000007);
				res[i][j]=(res[i][j]+g)%(1000000007);
			}
		}
	}
	return res;
}
public static long GCD(long a,long b) {
	if(b==(long)0) {
		return a;
	}
	return GCD(b , a%b);
}
public static long GCD_2(long a,long b) {
//	if(b==(long)0) {
//		return a;
//	}
//	if(a>=b) {
//	long c=a;
//	a=b;
//	b=c;}
//	return GCD_2(a,b-a);
	if (a == 0)
        return b;
      if (b == 0)
        return a;
    
      // base case
      if (a == b)
          return a;
    
      // a is greater
      if (a > b) {
          return GCD_2(a-b, b);}
      return GCD_2(a, b-a);
}
}