p = int(input()) dp = [0, 0, 0] ans = 0 plus = 10 ** (p - 1) for i in range(p): ans += (sum(dp) + 1) * plus plus //= 10 ndp = [0] * 3 for i in range(10): if i == 3: continue for j in range(3): ndp[(i + j) % 3] += dp[j] for i in range(1, 10): if i == 3: continue ndp[i % 3] += 1 dp = ndp print(ans + dp[0])