import sys from operator import itemgetter from collections import defaultdict, deque import heapq import bisect import math import itertools stdin=sys.stdin sys.setrecursionlimit(10 ** 8) ip=lambda: int(sp()) fp=lambda: float(sp()) lp=lambda:list(map(int,stdin.readline().split())) sp=lambda:stdin.readline().rstrip() Yp=lambda:print('Yes') Np=lambda:print('No') inf = 1 << 60 inf1 = float('inf') mod = 10 ** 9 + 7 mod = 998244353 eps = 1e-9 sortkey1 = itemgetter(0) sortkey2 = lambda x: (x[0], x[1]) ############################################################### P = ip() dp = [[0 for _ in range(3)]for _ in range(P + 1)] ## 3の倍数だけど3を使わないものを数える dp[0][0] = 1 for i in range(P): for dig in range(10): if dig == 3: continue for j in range(3): dp[i + 1][(j + dig) % 3] += dp[i][j] # 3なしで3の倍数 x = dp[P][0] # 3がつく y = pow(10, P) - pow(9, P) # 0を引く ans = x + y - 1 print(ans)