import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[][] dp = new long[n + 1][3]; dp[0][0] = 1; for (int i = 1; i <= n; i++) { for (int j = 0; j < 10; j++) { if (j == 3) { continue; } for (int k = 0; k < 3; k++) { dp[i][(k * 10 + j) % 3] += dp[i - 1][k]; } } } long sum = 0; for (long x : dp[n]) { sum += x; } long total = pow(10, n) - sum; long ans = total + dp[n][0] - 1; System.out.println(ans); } static long pow(long x, long times) { long ret = 1; for (int i = 0; i < times; i++) { ret *= x; } return ret; } }