let N = Int(readLine()!)!

var edges = Array(repeating: [Int](), count: N)
for _ in stride(from: 0, to: N - 1, by: 1) {
    let input = readLine()!.split(separator: " ").map{ Int($0)! }
    edges[input[0] - 1].append(input[1] - 1)
    edges[input[1] - 1].append(input[0] - 1)
}

var dp = Array(repeating: [true: Optional<Int>.none, false: Optional<Int>.none], count: N)

let divider = 1_000_000_007

func getNumberOfCombinations(_ rootNode: Int, _ previousNode: Int?,  _ canBeColoredBlack: Bool) -> Int {
    guard dp[rootNode][canBeColoredBlack]! == nil else {
        return dp[rootNode][canBeColoredBlack]!!
    }

    var numberOfCombinationsWhenBlack = canBeColoredBlack ? 1 : 0
    var numberOfCombinationsWhenWhite = 1

    for i in stride(from: 0, to: edges[rootNode].count, by: 1) {
        let nextNode = edges[rootNode][i]
        guard nextNode != previousNode else { continue }

        numberOfCombinationsWhenBlack = numberOfCombinationsWhenBlack * getNumberOfCombinations(nextNode, rootNode, false) % divider
        numberOfCombinationsWhenWhite = numberOfCombinationsWhenWhite * getNumberOfCombinations(nextNode, rootNode, true) % divider
    }

    dp[rootNode][canBeColoredBlack] = (numberOfCombinationsWhenBlack + numberOfCombinationsWhenWhite) % divider
    return dp[rootNode][canBeColoredBlack]!!
}

print(getNumberOfCombinations(0, nil, true))
