from sys import stdin, stdout, setrecursionlimit

from collections import deque, defaultdict, Counter

from heapq import heappush, heappop

from functools import lru_cache

import math



setrecursionlimit(10**6)

rl = lambda: stdin.readline()

rll = lambda: stdin.readline().split()

rli = lambda: list(map(int, stdin.readline().split()))

rlf = lambda: list(map(float, stdin.readline().split()))



INF, NINF = float('inf'), float('-inf')



def main():

	MOD = 10**9 + 7

	n = int(rl())

	G = [[] for _ in range(n)]

	for _ in range(n-1):

		u, v = rli()

		u -= 1

		v -= 1

		G[u].append(v)

		G[v].append(u)



	def dfs(node, prnt):

		w, b = 1, 1

		for nbhr in G[node]:

			if nbhr == prnt: continue

			nw, nb = dfs(nbhr, node)

			w *= (nw + nb)

			w %= MOD

			b *= nw 

			b %= MOD

		return w, b



	answ, ansb = dfs(0, -1)

	print(((answ + ansb) % MOD))



	stdout.close()



if __name__ == "__main__":

	main()
from sys import stdin, stdout, setrecursionlimit

from collections import deque, defaultdict, Counter

from heapq import heappush, heappop

from functools import lru_cache

import math



setrecursionlimit(10**6)

rl = lambda: stdin.readline()

rll = lambda: stdin.readline().split()

rli = lambda: list(map(int, stdin.readline().split()))

rlf = lambda: list(map(float, stdin.readline().split()))



INF, NINF = float('inf'), float('-inf')



def main():

	MOD = 10**9 + 7

	n = int(rl())

	G = [[] for _ in range(n)]

	for _ in range(n-1):

		u, v = rli()

		u -= 1

		v -= 1

		G[u].append(v)

		G[v].append(u)





	wb = [[1,1] for _ in range(n+1)]

	wb[n] = [0, 0]

	seen = [0 for _ in range(n)]

	stack = []

	stack.append((0, n))

	while stack:

		node, prnt = stack.pop()

		w, b = wb[node]

		if not seen[node]:

			seen[node] = 1

			stack.append((node, prnt))

			for nbhr in G[node]:

				if nbhr == prnt: continue

				stack.append((nbhr, node))

		else:

			pw, pb = wb[prnt]

			pw *= (w + b)

			pb *= w 

			wb[prnt] = [pw % MOD, pb % MOD]



	ans = (wb[0][0] + wb[0][1]) % MOD

	print(ans)

	stdout.close()



if __name__ == "__main__":

	main()
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
rlf = lambda: list(map(float, stdin.readline().split()))
INF, NINF = float("inf"), float("-inf")


def main():
    MOD = 10**9 + 7
    n = int(rl())
    G = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v = rli()
        u -= 1
        v -= 1
        G[u].append(v)
        G[v].append(u)

    def dfs(node, prnt):
        w, b = 1, 1
        for nbhr in G[node]:
            if nbhr == prnt:
                continue
            nw, nb = dfs(nbhr, node)
            w *= nw + nb
            w %= MOD
            b *= nw
            b %= MOD
        return w, b

    answ, ansb = dfs(0, -1)
    print(((answ + ansb) % MOD))
    stdout.close()


if __name__ == "__main__":
    main()

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
rlf = lambda: list(map(float, stdin.readline().split()))
INF, NINF = float("inf"), float("-inf")


def main():
    MOD = 10**9 + 7
    n = int(rl())
    G = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v = rli()
        u -= 1
        v -= 1
        G[u].append(v)
        G[v].append(u)
    wb = [[1, 1] for _ in range(n + 1)]
    wb[n] = [0, 0]
    seen = [0 for _ in range(n)]
    stack = []
    stack.append((0, n))
    while stack:
        node, prnt = stack.pop()
        w, b = wb[node]
        if not seen[node]:
            seen[node] = 1
            stack.append((node, prnt))
            for nbhr in G[node]:
                if nbhr == prnt:
                    continue
                stack.append((nbhr, node))
        else:
            pw, pb = wb[prnt]
            pw *= w + b
            pb *= w
            wb[prnt] = [pw % MOD, pb % MOD]
    ans = (wb[0][0] + wb[0][1]) % MOD
    print(ans)
    stdout.close()


if __name__ == "__main__":
    main()

- -    def dfs(node, prnt): -        w, b = 1, 1 -        for nbhr in G[node]: -            if nbhr == prnt: -                continue -            nw, nb = dfs(nbhr, node) -            w *= nw + nb -            w %= MOD -            b *= nw -            b %= MOD -        return w, b - -    answ, ansb = dfs(0, -1) -    print(((answ + ansb) % MOD)) +    wb = [[1, 1] for _ in range(n + 1)] +    wb[n] = [0, 0] +    seen = [0 for _ in range(n)] +    stack = [] +    stack.append((0, n)) +    while stack: +        node, prnt = stack.pop() +        w, b = wb[node] +        if not seen[node]: +            seen[node] = 1 +            stack.append((node, prnt)) +            for nbhr in G[node]: +                if nbhr == prnt: +                    continue +                stack.append((nbhr, node)) +        else: +            pw, pb = wb[prnt] +            pw *= w + b +            pb *= w +            wb[prnt] = [pw % MOD, pb % MOD] +    ans = (wb[0][0] + wb[0][1]) % MOD +    print(ans)