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.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;
	private static final int intINF = Integer.MAX_VALUE;
	private static final long longINF = Long.MAX_VALUE;

	private static void solve() {
		int n =sc.nextInt();
		if(n==0) {
			pw.print(1);
			return;
		}
		pw.print(new int[]{8,4,2,6}[(n-1)%4]);
	}

	// TEMPLATE

	private static myScanner sc;
	private static PrintWriter pw;

	private static final int numberOfTests = 1;

	private static final String nameOfInAndOutFile = "";
	private static final String fullNameInputFile = nameOfInAndOutFile + ".in";
	private static final String fullNameOutputFile = nameOfInAndOutFile + ".out";

	public static void main(String[] args) throws IOException {
		if (nameOfInAndOutFile.length() == 0) {
			setDefaultInAndOutPut();
		} else {
			setInAndOutPutFromFile();
		}
		for (int test = 1; test <= numberOfTests; test++) {
			solve();
			pw.flush();
		}

		pw.close();
	}

	private static void setDefaultInAndOutPut() {
		sc = new myScanner(new BufferedReader(new InputStreamReader(System.in)));
		pw = new PrintWriter(System.out);
	}

	private static void setInAndOutPutFromFile() throws IOException {
		sc = new myScanner(new BufferedReader(new FileReader(new File(fullNameInputFile))));
		pw = new PrintWriter(new File(fullNameOutputFile));
	}
}

class myScanner {
	private char[] buffer = new char[1 << 8];
	private int pos = 1;

	private BufferedReader reader;

	public myScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public boolean hasNext() {
		return pos > 0;
	}

	private void loadBuffer() {
		pos = 0;
		try {
			for (int i; (i = reader.read()) != -1;) {
				char c = (char) i;
				if (c != ' ' && c != '\n' && c != '\t' && c != '\r' && c != '\f') {
					if (pos == buffer.length)
						buffer = Arrays.copyOf(buffer, 2 * pos);
					buffer[pos++] = c;
				} else if (pos != 0)
					break;
			}
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}

	public String current() {
		return String.copyValueOf(buffer, 0, pos);
	}

	public String next() {
		loadBuffer();
		return current();
	}

	public String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}

	public int nextInt() {
		return nextInt(10);
	}

	public long nextLong() {
		return nextLong(10);
	}

	public int nextInt(int radix) {
		loadBuffer();
		int result = 0;
		int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
		for (checkValidNumber(pos > i); i < pos; i++) {
			int digit = buffer[i] - '0';
			checkValidNumber(0 <= digit && digit <= radix - 1);
			result = result * radix + digit;
		}
		return buffer[0] == '-' ? -result : result;
	}

	public long nextLong(int radix) {
		loadBuffer();
		long result = 0;
		int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
		for (checkValidNumber(pos > i); i < pos; i++) {
			int digit = buffer[i] - '0';
			checkValidNumber(0 <= digit && digit <= radix - 1);
			result = result * radix + digit;
		}
		return buffer[0] == '-' ? -result : result;
	}

	public int[] nextArrayInts(int size) {
		int[] input = new int[size];
		for (int i = 0; i < size; i++)
			input[i] = nextInt();
		return input;
	}

	public long[] nextArrayLongs(int size) {
		long[] input = new long[size];
		for (int i = 0; i < size; i++)
			input[i] = nextLong();
		return input;
	}

	public double nextDouble() {
		loadBuffer();
		long result = 0;
		int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
		long round = 1;
		final int radix = 10;
		boolean hasPoint = false;
		for (checkValidNumber(pos > i); i < pos; i++) {
			int digit = buffer[i] - '0';
			checkValidNumber((0 <= digit && digit <= radix - 1) || (!hasPoint && digit == -2));
			if (digit == -2)
				hasPoint = true;
			else {
				if (hasPoint)
					round *= radix;
				result = result * radix + digit;
			}

		}
		return buffer[0] == '-' ? -result / (1.0 * round) : result / (1.0 * round);
	}

	private void checkValidNumber(boolean condition) {
		if (!condition)
			throw new NumberFormatException(current());
	}
}