#include #include using namespace std; int main(void){ unsigned long long p; cin >> p; unsigned long long result1 = 0; unsigned long long result2 = 0; unsigned long long result3 = 0; // 3の倍数 result1 = (unsigned long long)(powl(10, p) / 3); // 3の付く数 unsigned long long init = 1; for (int i = 1; i <= p; i++) { if (i == 1) { result2 = init; } else { result2 = init * 9 + powl(10, i - 1); init = result2; } } // 3の倍数かつ3の付く数 init = 1; for (int i = 1; i <= p; i++) { if (i == 1) { result3 = init; } else { result3 = init * 3 + (init - 1) * 6 + (unsigned long long)(powl(10, i - 1) / 3) + 1; init = result3; } } // 出力 unsigned long long result = result1 + result2 - result3; printf("%llu\n", result); return 0; }