#include using namespace std; #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--) #define rep(i, n) for (ll i = 0; i < (n); i++) #define rep1(i, n) for (ll i = 1; i <= (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define pb push_back #define mp make_pair #define fst first #define snd second #define show(x) cout << #x << " = " << x << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define pii pair namespace is_stl_container_impl { template struct is_stl_container : false_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; template struct is_stl_container> : true_type { }; } // namespace is_stl_container_impl //type trait to utilize the implementation type traits as well as decay the type template struct is_stl_container { static constexpr bool const value = is_stl_container_impl::is_stl_container>::value; }; template typename enable_if::value, ostream&>::type operator<<(ostream& os, const T& container) { os << "["; for (const auto& p : container) { os << p << ","; } os << "]"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } using ll = long long; constexpr ll MOD = 1000000007; template constexpr T INF = numeric_limits::inf() / 100; constexpr int MAX = 1000000; ll dp[MAX + 1][3]; int main() { int N; cin >> N; for (int i = 0; i < 3; i++) { dp[i + 1][i] = 1; } for (int i = 2; i <= N; i++) { for (int j = 0; j < 3; j++) { const int p = i - j - 1; if (p > 0) { for (int k = 0; k < 3; k++) { if (k == j) { continue; } dp[i][j] += dp[p][k]; dp[i][j] = dp[i][j] % MOD; } } } } cout << (dp[N][0] + dp[N][1] + dp[N][2]) % MOD << endl; return 0; }