#include #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif // LOCAL_ #define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1); #define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3); #define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1); #define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1); #define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2); long dp[32][3][2]; int main() { dp[1][0][0] = 3; dp[1][0][1] = 1; dp[1][1][0] = 3; dp[1][1][1] = 0; dp[1][2][0] = 3; dp[1][2][1] = 0; int x; scanf("%d", &x); for(int i = 2; i <= x; ++i) { for(int j = 1; j < i; ++j) { for(int k = 1; k <= 9; ++k) { for(int m = 0; m < 3; ++m) { for(int c : {0, 1}) { dp[i][(m+k)%3][c||(k==3)] += dp[j][m][c]; } } } } } long res = -1; for(int i = 1; i <= x; ++i) { res += dp[i][0][0] + dp[i][0][1] + dp[i][1][1] + dp[i][2][1]; } printf("%ld\n", res); return 0; }