#include #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,b) FOR(i,0,b) #define X real() #define Y imag() #define F first #define S second #define PB(a) push_back(a) #define BE(c) c.begin(),c.end() using namespace std; typedef long long LL; typedef pair pr; typedef pair ppr; typedef priority_queue,greater > PQ; typedef vector Vpr; typedef vector VI; typedef complex cld; typedef vector Vcld; typedef map MP; const int SIZE=100010; const LL INF=1<<28; LL isT[20]={1},isnT[20]={8}; LL DP[21][3]; LL e(LL k){ LL ans=1; REP(i,k){ ans*=10; } return ans; } int main(){ int p; cin >>p; REP(i,p){ isT[i+1]=isnT[i]+isT[i]*10; isnT[i+1]=-isT[i+1]+(e(i+1))*9; } LL ans=0; REP(i,p){ ans+=isT[i]; } DP[0][0]=1; REP(i,p){ REP(j,10){ REP(k,3){ if(j==3) continue; DP[i+1][(j+k)%3]+=DP[i][k]; } } } cout << ans+DP[p][0]-1<< endl; }