import std.stdio; import std.algorithm; import std.range; import std.conv; import std.format; import std.array; import std.math; import std.string; import std.container; void main() { int N; readlnTo(N); auto dp = new int[][](1000001, 4); const int mod = 1000000007; dp[0][0] = 1; int val; foreach(i; 0..N) { foreach(j; 1..4) { if (i + j > N) continue; val = dp[i+j][j]; foreach(k; 0..4) { if (j == k) continue; val = (val + dp[i][k]) % mod; } dp[i+j][j] = val; } } int ans = 0; foreach(i; 1..4) ans = (ans + dp[N][i]) % mod; ans.writeln; } // helpers void readlnTo(T...)(ref T t) { auto s = readln.split; assert(s.length == t.length); foreach(ref ti; t) { ti = s[0].to!(typeof(ti)); s = s[1..$]; } }