#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; #include using mint = atcoder::modint; int main() { cin.tie(nullptr)->sync_with_stdio(false); int m; cin >> m; mint::set_mod(m); mint ans = 0; ans += 2017; ans += mint(2017 * 2017).pow(2017); cout << ans.val() << '\n'; return 0; }