#include using namespace std; typedef long long LL; struct cww{cww(){ ios::sync_with_stdio(false);cin.tie(0); }}star; #define fin "\n" #define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define fi first #define se second #define pb push_back #define DEBUG if(0) template inline void chmin(T &l,T r){l=min(l,r);} template inline void chmax(T &l,T r){l=max(l,r);} template istream& operator>>(istream &is,vector &v){ for(auto &it:v)is>>it; return is; } LL MOD; LL pow_mod(LL a,LL n){ LL res=1; LL b=1; a%=MOD; while(n>=b){ if(n&b) res=(res*a)%MOD; a=(a*a)%MOD; b<<=1; } return res; } int main(){ cin>>MOD; cout<<(2017+pow_mod(2017*2017%MOD,2017))%MOD<