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

import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
   /* private static Set<String> hnames = new HashSet<>();

    static void fillNames(String path) {
        try {
            File fileDir = new File(path);
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(new FileInputStream(fileDir), StandardCharsets.UTF_16));
            String str;
            while ((str = in.readLine()) != null) {
                int nbtabs = 13;
                Person person = new Person();
                while (nbtabs-- > 0) {
                    str = str.substring(str.indexOf('\t') + 1);
                    if (nbtabs == 9) {
                        person.setName(str.substring(0, str.indexOf('\t')));
                        hnames.add(person.getName());
                        break;
                    }
                }
            }
            in.close();
        } catch (Exception e) {
        }
    }

    static Map<String, Double> solve(String path) {
        Map<String, Double> hm = new HashMap<>();
        try {
            File fileDir = new File(path);
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(new FileInputStream(fileDir), StandardCharsets.UTF_16));
            String str;
            while ((str = in.readLine()) != null) {
                int nbtabs = 13;
                Person person = new Person();
                while (nbtabs-- > 0) {
                    str = str.substring(str.indexOf('\t') + 1);
                    if (nbtabs == 9) {
                        person.setName(str.substring(0, str.indexOf('\t')));
                    }
                    if (nbtabs == 5) {
                        String v;
                        if (str.charAt(0) == '"') {
                            v = str.substring(1, str.lastIndexOf('"')).replace(',', '.');
                            person.setMontant(Double.valueOf(v));
                        } else {
                            v = str.substring(0, str.indexOf('\t'));
                        }
                        person.setMontant(Double.valueOf(v));
                    }
                }
                hm.put(person.getName(), person.getMontant() + hm.getOrDefault(person.getName(), 0.0));
            }
            in.close();
        } catch (Exception e) {
        }
        return hm;
    }

    static String[][] tomatrix() {
        String[][] matrix = new String[hnames.size() + 1][13];
        int i = 1;
        for (String n : hnames) {
            matrix[i++][0] = n;
        }
        for (int j = 1; j <= 12; j++) {
            matrix[0][j] = Month.values()[j-1].toString();
        }
        return matrix;
    }

    static void writeToFile(String[][] mat) throws FileNotFoundException {
        File f = new File("C:\\Users\\El king\\Desktop\\Mon doc\\dad.txt");
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f,false), StandardCharsets.UTF_16));
        try {
            for (int i = 1; i <=hnames.size(); ++i) {
                StringBuilder stringBuilder = new StringBuilder();
                for (int j = 0; j <=12 ; ++j) {
                        stringBuilder.append(mat[i][j]).append(',');
                }
                bufferedWriter.write(stringBuilder.toString());
                bufferedWriter.newLine();
            }
            bufferedWriter.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    static void execute() throws FileNotFoundException {
        for (int i = 5; i <= 12; ++i) {
            fillNames("C:/Users/El king/Desktop/Mon doc/OP_48_2018 - Copie" + i + ".csv");
        }
        String[][] matrix = tomatrix();
        for (int i = 1; i <= hnames.size(); ++i) {
            for (int k = 1; k <= 12; ++k) {
                Map<String, Double> hl = solve("C:/Users/El king/Desktop/Mon doc/OP_48_2018 - Copie" + k + ".csv");
                if (hl.containsKey(matrix[i][0]))
                    matrix[i][k] = String.valueOf(hl.get(matrix[i][0]));
            }
        }
        for (int i = 1; i <= hnames.size(); ++i) {
            for (int k = 1; k <= 12; ++k) {
                if (matrix[i][k]==null){
                    matrix[i][k]="0";
                }
            }
        }
        writeToFile(matrix);
    }*/

    private static void run() {
        int n = sc.nextInt();
        if (n==0){
            System.out.println("1");return;
        }
        if (n%2==0){
            if ((n/2)%2==0) System.out.println("6");
            else System.out.println("4");
        }else{
            int l=1<<1;
            if ((n&l)!=0 && (n&1)!=0) System.out.println("2");
            else System.out.println("8");
        }

    }

    public static void main(String[] args) throws IOException {
        run();
    }
}