//费马小定理降幂+快速幂
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn=1e5+5;
const int MD=1e9+6;
char s[maxn];
int len;
LL quick_mod(LL a,LL b,LL mod)
{
LL ans=1;
while(b)
{
if(b&1) ans=(ans*a)%mod;
b>>=1;
a=(a*a)%mod;
}
return ans;
}
int main()
{
while(scanf("%s",s)==1)
{
LL solve=0;
len=strlen(s);
for(int i=0;i<len;i++)
{
solve=(solve*10%MD+(s[i]-'0'))%MD;
}
solve%=MD;
if(solve) {
if(solve!=1) printf("%lld\n",quick_mod(2,solve-1,MD+1));
else if(solve==1) printf("1\n");
}
else printf("%lld\n",quick_mod(2,MD-1,MD+1));
}
return 0;
}