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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.util.*;


public class B {
	
	static int mod=(int)Math.pow(10, 9)+7;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
	    FastScanner fs=new FastScanner();
	    int n=fs.nextInt();
	    int arr[]= {6,8,4,3};
	    if(n==0) System.out.println(1);
	    else {
	    	System.out.println(arr[n%4]);
	    }
	    
	}
	public static int solve(int n, ArrayList<ArrayList<Integer>> enemy) {
        Map<Integer,Set<Integer>> map=new HashMap<>();
        for(int i=1;i<=n;i++){
            map.put(i,new HashSet<>());
            for(int j=1;j<=n;j++){
                if(i!=j)
                map.get(i).add(j);
                
            }
        }
        boolean vst[]=new boolean[n+1];
        
        for(ArrayList<Integer> list:enemy){
            int u=list.get(0),v=list.get(1);
            map.get(u).remove(v);
            map.get(v).remove(u);
        }
        int cmp=0;
        for(int i=1;i<=n;i++){
            if(!vst[i]){
                dfs(i,map,vst);
                cmp++;
            }
        }
        System.out.println(cmp);
        if(cmp>2) return 0;
        return 1;
    }
    static void dfs(int st,Map<Integer,Set<Integer>> map,boolean vst[]){
        vst[st]=true;
        for(int next:map.get(st)){
            if(!vst[next]) dfs(next,map,vst);
        }
    }
	static void mysort(long[] a) {
		//suffle
		int n=a.length;
		Random r=new Random();
		for (int i=0; i<a.length; i++) {
			int oi=r.nextInt(n);
			long temp=a[i];
			a[i]=a[oi];
			a[oi]=temp;
		}
		
		//then sort
		Arrays.sort(a);
	}
	
	// Use this to input code since it is faster than a Scanner
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
 
}