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.
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
// package coding;

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

/**
 *
 * @author Mostafa
 */
public class Coding {

            /**
             * @param args the command line arguments
             */

            public static class FastReaderFile
            {
                        BufferedReader br;
                        StringTokenizer st;
                        public FastReaderFile(InputStream in)
                        {
                            br = new BufferedReader(new
                                     InputStreamReader(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 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 PrintWriter out;
            public static int ser ( int x[] , int start , int end , int val )
            {
                        while ( start <= end )
                        {
                                int mid = ( start + end ) / 2 ;
                                if ( x[mid] == val )
                                        return mid ;
                                if ( x[ mid ] <= val )
                                    start = mid + 1 ;
                                else
                                    end = mid - 1 ;
                        }
                return -1 ;
            }

         public static  boolean isPrime( long n)
        {
                if (n < 2)  return false;
                if (n < 4)  return true;

                if (n%2 == 0 || n%3 == 0) return false;

                for (long i = 5 ; i * i <= n ; i = i + 6 )
                        if ( n % i == 0 || n % ( i + 2 ) == 0)
                                return false ;

                return true;
        }



            static long gcd(long a, long b) 
            {
                  return b == 0 ? (a < 0 ? -a : a) : gcd(b, a % b);
            }


            static long lcm(long a, long b)
            {
                        long lcm = (a / gcd(a, b)) * b;
                        return lcm > 0 ? lcm : -lcm ;
            }



            public static int search( int x[] , int val )
            {
                        return ser( x , 0 , x.length - 1 , val  );
            }
            public static String remove ( String s , int i )
            {
                        return s.substring(0, i) + s.substring(i+1) ;
            }
            public static long ret( long x , long st ,  long y  )
            {
                    int i = 0 ;
                    return i ;
            }

//            for (Map.Entry<Integer, Integer> e : x.entrySet()) 
//                        {
//                            e.getValue() , e.getKey

                public static void main(String[] args) throws FileNotFoundException {
//                     TODO code application logic here
                    FastReader in = new FastReader();
//                    Scanner in = new Scanner(System.in) ;
//                    FastReaderFile in = new FastReaderFile(new FileInputStream("fruits.in")) ;
                    StringBuilder r = new StringBuilder();
                    out = new PrintWriter(new BufferedOutputStream(System.out), true) ;
                    long n = in.nextLong()  ;
                    if ( n == 0 )
                    {
                            out.println(1);
                            return ;
                    }
                int a = (int) n%4 ;
                switch (a) {
                        case 1:
                                out.println(      8       ) ;
                                break;
                        case 2:
                                out.println(      4       ) ;
                                break;
                        case 3:
                                out.println(      2       ) ;
                                break;
                        default:
                                out.println(      6       ) ;
                                break;
                }
        }
}