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