#include int main(void){ int N; std::cin >> N; int ans[] = {7, 8, 9, 4, 5, 6, 1, 2, 3, 0}; std::cout << ans[N-1]; }