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


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();
     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;
    }

}
