#include <stdio.h>
#include <string.h>

#define MAT_ORDER 3
#define MOD 1000000007

typedef long long sqmat_t[MAT_ORDER][MAT_ORDER];

void multiSqMat(sqmat_t Z, const sqmat_t X, const sqmat_t Y) {
	int i, j, k;
	for (i = 0; i < MAT_ORDER; i++)
		for (j = 0; j < MAT_ORDER; j++) {
			Z[i][j] = 0;
			for (k = 0; k < MAT_ORDER; k++) {
				Z[i][j] += X[i][k] * Y[k][j];
				Z[i][j] %= MOD;
			}
		}
}

void fastPowMat(sqmat_t Y, const sqmat_t X, long long n) {
	int i;
	sqmat_t tmp;
	sqmat_t XX, prod = {0};

	memcpy(XX, X, sizeof(sqmat_t));
	for (i = 0; i < MAT_ORDER; i++)
		prod[i][i] = 1;

	while (n) {
		if (n & 1) {
			multiSqMat(tmp, prod, XX);
			memcpy(prod, tmp, sizeof(sqmat_t));
		}

		multiSqMat(tmp, XX, XX);
		memcpy(XX, tmp, sizeof(sqmat_t));

		n >>= 1;
	}

	memcpy(Y, prod, sizeof(sqmat_t));
}

int main(void) {
	int n;
	sqmat_t tmp;
	const sqmat_t Q = {{0, 1, 0}, {0, 0, 1}, {1, 1, 0}};

	scanf("%d", &n);

	fastPowMat(tmp, Q, n);

	printf("%lld\n", (tmp[0][2] + tmp[1][2] + tmp[2][2]) % MOD);

	return 0;
}