#include using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v).end() templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> p; ll dp[p+1][2][3]={}; dp[0][0][0]=1; REP(i,p){ REP(j,2){ REP(k,3){ REP(l,10){ if(!j&&l==3){ dp[i+1][1][(k+l)%3]+=dp[i][j][k]; } else{ dp[i+1][j][(k+l)%3]+=dp[i][j][k]; } } } } } ll ans=dp[p][0][0]; REP(i,3) ans+=dp[p][1][i]; cout << ans-1 << endl; }