TIMELIMIT
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
std::ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int n; cin>>n;
int mod=n+2;
int ans=1;
for( int i=1;i<=n;++i) {//n<=2147483647,一定会超时,来自初学者的津津菜鸟
ans=ans*2;
ans=ans%mod;
}
cout<<ans;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
//一定要养成好习惯
#define endl '\n'
#define int long long
int pows(int a,int b,int mod){int ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans%mod;}
//int find(int x){return p[x]==x?x:(p[x]=find(p[x]));}
//int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
void solve()
{
int n;
cin>>n;
cout<<pows(n,n,n+2)<<endl;
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
solve();
}