#if !__INCLUDE_LEVEL__ #include __FILE__ int main(void){ ll n; cin >> n; n++; vector dp(n+1, vector>>(2, vector>(2, vector(3, 0)))); dp[0][0][0][0] = 1; rep(i,n) rep(j,2) rep(k,2) rep(l,3) { ll lim = j ? 9 : (!i ? 1 : 0); rep(d,lim+1) dp[i+1][j || d < lim][k || d == 3][(l+d)%3] += dp[i][j][k][l]; } ll ans = 0; rep(i,3) rep(j,2) ans += dp[n][j][1][i]; rep(j,2) ans += dp[n][j][0][0]; cout << ans-1 << '\n'; } /*---------------------------------------------------------------------------------------------------       ○______       ||      |       ||  ●   |       ||      |     || ̄ ̄ ̄ ̄ ̄      || 君が代は ∧__,,∧||  千代に八千代に   ( `・ω・|| さざれ石の巌となりて   ヽ つ0 こけのむすまで    し―-J ---------------------------------------------------------------------------------------------------*/ #else #include using namespace std; #include using namespace atcoder; using ll = long long; using ull = unsigned long long; using ldb = long double; using P = pair; #define fi first #define se second #define m_99(i,a,b) for (ll i = a, i##_range = (b); i < i##_range; i++) #define rep(i,a) m_99(i,0,a) template bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; } template bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; } #ifdef LOCAL #include #define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif struct initialise { initialise() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }__INI__; const ll inf = 1LL << 60; const ll dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1}; #endif