#include #include int p; long long dp[19][10][2]; long long rec(int index, int remainder, bool hasThree){ if(index == p){return remainder == 0 || hasThree;} auto& res = dp[index][remainder][hasThree]; if(res != -1){return res;} res = 0; for(int i=0;i<=9;i++){ res += rec(index+1, (remainder+i) % 3, hasThree || i == 3); } return res; } int main(){ scanf("%d", &p); memset(dp, -1ll, sizeof(dp)); printf("%lld\n", rec(0, 0, false) - 1); }