class MatrixExponentiation(var vec: LongArray, var matrix: Array<LongArray>, var k: Int) {

    private val mod: Long = 1_000_000_007

    public fun matrixPow(): Unit {
        k -= 1
        while (k > 0) {
            if (k % 2 == 1) {
                vec = matrixExp()
            }
            matrix = updateMatrix()
            k /= 2
        }
    }

    private fun matrixExp(): LongArray {
        val size = vec.size
        var ret = LongArray(size) // initialize
        for (i in 0 until size) {
            for (j in 0 until size) {
                ret[i] += (matrix[i][j] * vec[j]) % mod
            }
            ret[i] %= mod
        }
        return ret
    }

    private fun updateMatrix(): Array<LongArray> {
        val size = matrix.size
        var ret = Array(size) { LongArray(size) } // initialize
        for (i in 0 until size) {
            for (j in 0 until size) {
                for (k in 0 until size) {
                    ret[i][j] += (matrix[i][k] * matrix[k][j]) % mod
                }
                ret[i][j] %= mod
            }
        }
        return ret
    }

    private fun printMatrix(matrix: Array<LongArray>): Unit {
        print("[")
        for (i in matrix.indices) {
            if (i == 0) print("[") else print(" [")
            for (j in matrix.indices) {
                print(matrix[i][j])
                if (j != matrix.size - 1) print(", ")
            }
            if (i != matrix.size - 1) {
                println("],")
            } else {
                print("]")
            }
        }
        println("]")
    }
}

public fun readln() = readLine()!!
public fun readlnByte() = readln().toByte()
public fun readlnShort() = readln().toShort()
public fun readlnInt() = readln().toInt()

fun main() {
    val s = readlnInt()
    val vec = longArrayOf(0, 0, 1)
    val matrix = arrayOf( longArrayOf(1, 0, 1), longArrayOf(1, 0, 0), longArrayOf(0, 1, 0) )
    val me = MatrixExponentiation(vec, matrix, s)
    me.matrixPow()
    println(me.vec[1])
}