#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; long long k=pow(8,n); cout<<k%10; return 0; }