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.
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays;
import java.util.HashSet; 

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef{
	
	static long digit(long n) {
				
		long temp =n;
		long cc=0;
		while(temp-->0) {
			n = n*10;
		}
		return n;
		
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		FastReader sc = new FastReader();
	    PrintWriter out = new PrintWriter(System.out, true);
		int t=1;
		while(t-->0){		
			long n = sc.nextLong();
			if(n==0)
				System.out.println(1);
			else if(n%8==1||n%8==5)
				System.out.println(8);
			else if(n%8==2||n%8==6)
				System.out.println(4);
			else if(n%8==3||n%8==7)
				System.out.println(2);
			else if(n%8==4||n%8==0)
				System.out.println(6);
			
			//System.out.println(999999997%8);
		}
	}
		static class FastReader {
	    BufferedReader in;
	    StringTokenizer st;
	    
	    public FastReader() {
	        in = new BufferedReader(new InputStreamReader(System.in));
	    }
	    
	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try {
	                st = new StringTokenizer(in.readLine());
	            }
	            catch (Exception IO) {
	                IO.printStackTrace();
	            }
	        }
	        
	        return st.nextToken();
	    }
	    
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	    
	    int nextInt() {
	        return Integer.parseInt(next());
	    }
	    
	    Double nextDouble() {
	        return Double.parseDouble(next());
	    }
	    
	    String nextLine() {
	        String str = "";
	        try {
	            str = in.readLine();
	        } catch(Exception IO) {
	            IO.printStackTrace();
	        }
	        
	        return str;
	    }
	    
	    long[] nextLongArray(int size) {
	        long[] arr = new long[size];
	        
	        for (int i = 0; i < size; i++) {
	            arr[i] = this.nextLong();
	        }
	        
	        return arr;
	    }
	    
	    int[] nextIntegerArray(int size) {
	        int[] arr = new int[size];
	        
	        for (int i = 0; i < size; i++) {
	            arr[i] = this.nextInt();
	        }
	        
	        return arr;
	    }
	    
	    double[] nextDoubleArray(int size) {
	        double[] arr = new double[size];
	        
	        for (int i = 0; i < size; i++) {
	            arr[i] = this.nextDouble();
	        }
	        
	        return arr;
	    }
	    
	    void printArray(Object[] arr) {
	        for (int i = 0; i < arr.length; i++) {
	            System.out.println(arr[i] + " ");
	        }
	        System.out.println();
	    }
	}
}