n = gets.to_i dp = 4.times.map { Array.new(n + 1, 0) } dp[1][1] = 1 dp[2][2] = 1 dp[3][3] = 1 dp[1][3] = 1 dp[2][3] = 1 (4 .. n).each do |j| dp[1][j] = dp[2][j - 1] + dp[3][j - 1] dp[2][j] = dp[1][j - 2] + dp[3][j - 2] dp[3][j] = dp[1][j - 3] + dp[2][j - 3] end puts (dp[1][n] + dp[2][n] + dp[3][n]) % 1000_000_007