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

 /*بسم الله الله أكبر"*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstring>
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<time.h>
#include<unistd.h>
#include<windows.h>
using namespace std;
typedef  long long ll ;
typedef vector<ll>vl;
typedef long double ld;
#define all(v) ((v).begin()), ((v).end())
#define boom main
#define cn(n)  scanf("%d", &n)
#define cnl(n)  scanf("%lld", &n)
#define F(i, a, b) for(int i=a; i<=b; i++)
#define rep(i, n) for(int i=0; i<n; i++)
#define Fill(ar, val) memset(ar, val, sizeof(ar))
#define bit(n) (1<<(n))
#define   fn           "\n"
#define Abdo   std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e18+7;
int gcd(int a, int b)
{
    return !b ? a : gcd(b, a % b);
}
int lcm(int a, int b){return (a / gcd(a, b)) * b;}
ll power(ll x, ll y)
{
    if (y == 0)return 1;
    if (y == 1)return x;
    ll r = power(x, y / 2) % mod;
    return r%mod*r%mod*power(x, y % 2) % mod;
}
const ld EPS = 1e-9, PI = 3.141592653589793238462643383279502884;
const long long N =  1e5+10, M = 2e3 + 15, OO =  numeric_limits<ll>::max();;

int dx[] = { 0,  -1, 0, 1 };
int dy[] = { -1, 0,  1,  0 };


int boom(void)
{

   ll n;
   cin>>n;
   cout<<power(8 , n)%10;
}
