d = {} def get(x,r,f): if (x,r,f) in d: return d[x,r,f] if x < 0: return 0 if x==0: return 1 if r == 0 or f == 1 else 0 res = sum(get((x-i)//10, (r-i)%3, f|(i==3)) for i in range(10)) d[x,r,f] = res return res n = int(input()) print(get(10**n,0,0)-1)