#include using namespace std; int main() { int m; cin >> m; int a = 2017 % m; int b = (2017 * 2017) % m; int c = 1; for (int i = 0; i < 2017; i++) { c = (c*b) % 2017; } int ans = (a + c) % 2017; cout << ans << endl; system("pause"); return 0; }