#include using namespace std; int main() { int n; string s = "428571"; cin >> n; cout << s[n%6] << endl; return 0; }