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.
/**
 * DA-IICT
 * Author : Savaliya Sagar.
 */

import java.io.*;
import java.math.*;
import java.util.*;

public class A742 {
    public static int mod = 1000000007;
    static FasterScanner in = new FasterScanner();
    static PrintWriter o = new PrintWriter(System.out);

    public static void main(String[] args) {


        long n = in.nextLong();
     //   o.print(1378L*1378);
        if(n==0)
            o.print(1);
        else if (n%4==0)
            o.print(6);
        else if(n%4==1)
            o.print(8);
        else if(n%4==2)
            o.print(4);
        else if(n%4==3)
            o.print(2);
        o.close();
    }


    public static long gcd(long n1, long n2) {
        long r;
        while (n2 != 0) {
            r = n1 % n2;
            n1 = n2;
            n2 = r;
        }
        return n1;
    }

    public static long pow(long x, long n, long mod) {
        long res = 1;
        x %= mod;
        while (n > 0) {
            if (n % 2 == 1) {
                res = (res * x) % mod;
            }
            x = (x * x) % mod;
            n /= 2;
        }
        return res;
    }

    static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int snumChars;

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n, int f) {
            if (f == 0) {
                int[] arr = new int[n];
                for (int i = 0; i < n; i++) {
                    arr[i] = nextInt();
                }
                return arr;
            } else {
                int[] arr = new int[n + 1];
                for (int i = 1; i < n + 1; i++) {
                    arr[i] = nextInt();
                }
                return arr;
            }
        }

        public long[] nextLongArray(int n, int f) {
            if (f == 0) {
                long[] arr = new long[n];
                for (int i = 0; i < n; i++) {
                    arr[i] = nextLong();
                }
                return arr;
            } else {
                long[] arr = new long[n + 1];
                for (int i = 1; i < n + 1; i++) {
                    arr[i] = nextLong();
                }
                return arr;
            }
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}
