#include using namespace std; int n, a[10] = { 7, 8, 9, 4, 5, 6, 1, 2, 3, 0 }; int main() { cin >> n; n--; cout << a[n - 1] << endl; return 0; }