#include <bits/stdc++.h>
using namespace std;

int main() {
	int x = 1;
	for (int i = 1; i <= 100000000; i++) {
		x *= 4;
		x %= 50;
		x /= 2;
		x %= 10;
	}
	cout << x << endl;
}