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.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		FastReader scan = new FastReader();
		
		int n = scan.nextInt();
		int ans = 0;
		
		switch(n%4) {
		case 0: ans = 6;
		break;
		case 1: ans = 8;
		break;
		case 2: ans = 4;
		break;
		case 3: ans = 2;
		break;
		}
		
		System.out.println(ans);
		
  }
	
	//smallestFactor function
	public static long smallestFactor(long n) {
		int i;
		for(i=2; i<n; i++) {
			if(n%i == 0) 
				break;
		}
		return i;
	}

	//FastReader Class
	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; 
		} 
	}  
}
