n=int(input()) edge=[[]for _ in range(n)] to=[0]*n p=[1]*n for _ in range(n-1): a,b=map(int,input().split()) a-=1 b-=1 edge[a].append(b) to[b]+=1 stack=[i for i in range(n) if to[i]==0] visited=set(stack) mod=10**9+7 for i in stack: for j in edge[i]: if j in visited:continue visited.add(j) to[j]-=1 if to[j]==0:stack.append(j) p[j]+=p[i] p[j]%=mod print(sum(p)%mod)