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.
 */

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

/**
 *
 * @author Ahmed
 */
public class Watermelon {

    public static boolean state;
    public static int countA = 0, countB = 0;

    private static int mod(int x, int y) {
        int result = x % y;
        return result < 0 ? result + y : result;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner in = new Scanner(System.in);
        
       // String str = in.next();
        
   
     int n = in.nextInt();
     if(n == 0)
     {
       System.out.println(1);
       return;
     }
     int arr[] = new int[]{8 , 4 , 2 , 6 };
     int index = mod(n-1 , 4);
        System.out.println(arr[index]);
      
/*
        int n = in.nextInt(), index = 0, max = 0;
        int arr[] = new int[n];
        ArrayList<Integer> list = new ArrayList();
        for (int i = 0; i < arr.length; ++i) {
            int num = in.nextInt();
            list.add(num);
            max = Math.max(num, max);
        }

        for (int i = 0; i < list.size(); ++i) {
            if (i == list.get(i)) {
                continue;
            }
            index = mod(list.get(i), n);
            if (index == list.get(i) && list.get(index) != list.get(i)) {
                int temp = list.get(index);
                list.set(index, index);
                list.set(i, temp);
                --i;
            }
        }

        for (int i = 1; i < list.size(); ++i) {

            if (list.get(i) != i) {
                System.out.println("the missing numer is :" + i);
                return;
            }
        }
        System.out.println("the missing numer is :" + (max + 1));

        /*   for(int i = 0 ; i < n.length() ; ++i)
        {
           if(map.containsKey(n.charAt(i)))
           {
             if(map.get(n.charAt(i)) <= min)
             {
                 min = map.get(n.charAt(i));
                 v = n.charAt(i);
             }
           }
           else{
               map.put(n.charAt(i), i);
           }
        }*/
 /*
        int n = in.nextInt(), k =  in.nextInt();
        
        if(n % 2 == 0)
        {
            int num = n / 2;
            if(k >= num)
            {
               int s = n - k ;
               System.out.println((n) - (s * 2));  
            }
            else{
                int s = num - k ;
                System.out.println((n-1) - (s * 2));
            }
        }
        else{
             int num = (n+1) / 2;
            if(k >= num)
            {
               int s = (n-1) - k ;
               System.out.println((n) - (s * 2));  
            }
            else{
                int s = num - k ;
                System.out.println((n-1) - (s * 2));
            }
        }
         */
 /*  String str = in.next();
        HashMap<String , Character> map = new HashMap();
        
        String s = "abcdefghijklmnopqrstuvwxyz";
        for(int i = 0 ; i < s.length() ; ++i)
        {
            map.put(""+(i+1) , s.charAt(i));
        }
         */
 /*
        int n = in.nextInt();
        int arr[] = new int[n];
        
        int count = 0 ; 
        ArrayList<Integer> list = new ArrayList();
        for(int i = 0 ; i < n ; ++i)
        {
           arr[i] = in.nextInt();
           count = count + arr[i] ;
           if(count < n)
           {
               System.out.println("");
               list.add(arr[i]);
           }
           else{
               list.add(arr[i]);
              // System.out.println("");
               for(int j = list.size() - 1 ; j >= 0  ; --j)
               {
                   System.out.print(list.get(j) + " ");
               }
               count = 0 ;
               list = new ArrayList(); 
               System.out.println("");
           }
        }*/
    }

}

class obj {

    private int max;
    private int min;

    public obj(int max, int min) {
        this.max = max;
        this.min = min;
    }

    /**
     * @return the max
     */
    public int getMax() {
        return max;
    }

    /**
     * @return the min
     */
    public int getMin() {
        return min;
    }

}
