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