#include using namespace std; #define rep(i,a,b) for(int i=a;i 0) { if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; } int modinv(int a) { return modpow(a, mod - 2); } //----------------------------------------------------------------- int main() { cin >> mod; int ret = 2017 % mod; int d = modpow((2017 * 2017) % mod, 2017); int ans = (ret + d) % mod; cout << ans << endl; }