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 Solve{
    static final int MOD=1000000007;
   
    public static void main (String[] args) throws Exception{
         BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
          PrintWriter out=new  PrintWriter(System.out,true);
        
       
          int t=1;

        while(t-->0)
          solve(in,out);
       
    }

    private static void solve(BufferedReader in,PrintWriter out)throws Exception {
       int n=Integer.parseInt(in.readLine());
       long s=power(8, n, MOD);
       out.println(s%10);
      }

      private static long power(long n,long p,long m){
        
        long result=1;

        while(p>0){
            if(p%2==1) result=(result*n)%m;
            n=(n*n)%m;
            p/=2;
        }
        return result;
    }

   private int gcd(int a, int b) {
        if(b==0)
            return a;
        else
            return gcd(b, a % b);
    }


    private static void sieve(int n){
         boolean[] prime=new boolean[n];
         for(int i=0;i<n;i++)
             prime[i]=true;
         for(int i=2;i*i<n;i++){
            if(prime[i]){
                for(int j=i*i;j<n;j+=i)
                 prime[j]=false;
            }
        }
         for ( int i = 2; i < prime.length; i++) {
             if(prime[i])
              System.out.print(i+" ");
         }  
         
    
    }

    private static void segmentedSieve(int low,int high){

        int sqrt=(int) Math.sqrt(high);
        int[] prime=new int[sqrt+1];
        boolean[] arr=new boolean[sqrt+1];

        for(int i=0;i<=sqrt;i++)
            arr[i]=true;

        int k=0;
        for(int i=2;i<=sqrt;i++){           //generate all prime numbers till square root of high
            if(arr[i]){
                prime[k]=i;
                
                k++;
                for (int j = i*i; j <= sqrt; j+=i) 
                    arr[j]=false;
        
                
             }
        }
        // System.out.println(Arrays.toString(prime));

        int diff=high-low+1;          // arr size of required length 
        arr=new boolean[diff];
        for(int i=0;i<diff;i++)
             arr[i]=true;
        
        for(int i=0;i<k;i++){               // mark false to multiple of prime numbers in the range of low to high
            int div=(low/prime[i])*prime[i];        // It gives multiple of prime[i] nearest to low 
            if(div<low || div==prime[i])
               div+=prime[i];
            for(int j=div;j<=high;j+=prime[i]){
                 if(j!=prime[i])
               arr[j-low]=false;
            }
        }
        for(int i=0;i<diff;i++){                //print prime numbers in the given segment
            if(arr[i] && (i+low)!=1){
                System.out.print(i+low+" ");
            }
        }
        System.out.println();

    }

    class Pair implements Comparable<Pair>{
        int a;
        int b;
        public Pair(int a,int b){
            this.a=a;
            this.b=b;
        }
    
        @Override
        public int compareTo(Pair o) {
          if(this.a>o.a) return this.a-o.a;
          else if(this.a<o.a)
              return this.b-o.b;
          
          else  return 0;
         
        }
    }
}
