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.
/* 
A. Arpa’s hard exam and Mehrdad’s naive cheat
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.


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
inputCopy
1
outputCopy
8
inputCopy
2
outputCopy
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.util.*;
import java.io.*;
import java.lang.*;

public class MainClass {
	
    private static BufferedReader br = null;
	private static StringTokenizer st = null;
	
	static {	
		br = new BufferedReader(new InputStreamReader(System.in));
	}
	
	public static String strs() throws IOException {
		return br.readLine();
	}
	
	public static String[] strs(int N) throws IOException {
		st = new StringTokenizer(strs());
		String[] arr = new String[N];
		for(int i = 0; i < N; i += 1) {
			arr[i] = st.nextToken();
		}
		return arr;
	}
	
	public static int ints() throws IOException {
		return Integer.parseInt(strs());
	}
	
	public static int[] ints(int N) throws IOException {
		st = new StringTokenizer(strs());
		int[] nums = new int[N];
		for(int i = 0; i < N; i += 1) {
			nums[i] = Integer.parseInt(st.nextToken());
		}
		return nums;
	}
	
	public static long longs() throws IOException {
		return Long.parseLong(strs());
	}
	
	public static long[] longs(int N) throws IOException {
		st = new StringTokenizer(strs());
		long[] nums = new long[N];
		for(int i = 0; i < N; i += 1) {
			nums[i] = Long.parseLong(st.nextToken());
		}
		return nums;
	}
	
	public static void main(String[] args) throws IOException {
		//int T = ints();
		//for(int i = 1; i <= T; i += 1) {
			//int[] nums = ints(3);
            //int A = nums[0], B = nums[1], N = nums[2];
			Solution obj = new Solution();
			int N = ints();
            System.out.println(obj.last_digit(N));	
		//}
		br.close();
    }
}

class Solution {
	private long power(long num, long N, long P) {
        long res = 1;
		while(N > 0) {
			if(N % 2 == 1) {
				res = (res * num) % P;
			}
			
			num = (num * num) % P;
			
			N /= 2;
		}
		
		return res;
    }
	
	/* 
		As we know that if two numbers a and b are congruence to each other
		then
			a^k is congruence to b^k
			
		Here in the above question -> 1378^n is congruence to 8 modulo 10
		
		1378^n % 10 is congruence to  8^n % 10
		
		so instead of calculating 1378^n we can calculate 8^n and then return 
		last digit of 8^n.
		
		1378^1 -> 1378 % 10 -> 8
		
		8^1 -> 8 % 10 -> 8
		
		1378^2 -> 1898884 % 10 -> 4
		
		8^2 -> 64 % 10 -> 4
		
		1378^n and 8^n is leaving same remainder under modulo 10.
		
		that's why both of them are congruence to each other.
	*/
	
	public int last_digit(int N) {
		int last_digit = (int)power(1378, N, 10);
		//int last_digit = (int)power(8, N, 10););
		return last_digit;
	}
}
