12
 1378
 51202278
 989898989
 4
 7
 9
 6
 8
 12193721
 999999995
 999999999
 11
 999999996
 999999998
 3
 14
 15
 10
 999999994
 1000
 13781378
 5
 999999997
 1000000000
 13
 16
 0

6
 4
 4
 8
 6
 2
 8
 4
 6
 8
 2
 2
 2
 6
 4
 2
 4
 2
 4
 4
 6
 4
 8
 8
 6
 8
 6
 1

/*
 * 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;
                }
        }
}