#include using namespace std; using ll = long long; int main() { int P; cin >> P; vector now(4); now[0] = 1; while (P--) { vector nxt(4); for (int i = 0; i < 10; i++) { if (i == 3) nxt[3] += accumulate(now.begin(), now.begin() + 3, 0ll); else for (int j = 0; j < 3; j++) nxt[(j + i) % 3] += now[j]; } nxt[3] += now[3] * 10; swap(now, nxt); } now[0]--; cout << now[0] + now[3] << endl; }