#include int val[6] = {2, 8, 5, 7, 1, 4}; int main() { int n; scanf("%d", &n); printf("%d\n", val[(n-1)%6]); return 0; }