//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
using namespace std::chrono;
long long int p=1e9 +7;
int n;
vector<int> edge[100000];
bool debugging=0;
bool outputcheck=0;
bool timecheck=0;
void init(){
    if(debugging){
        
    }
    else{
        cin>>n;
        for(int i=0;i<n-1;i++){
            int a,b;
            cin>>a>>b;
            edge[--a].pb(--b);
            edge[b].pb(a);
        }
    }
}
long long int modpower(ll b,ll po, ll mod=p){
    long long int ans=1;
    while(po){
        if(po&1){
            ans*=b;
            ans%=mod;
        }
        b*=b;
        b%=mod;
        po>>=1;
    }
    return ans;
}
ll solve(){
  queue<pair<int,int>> tochk;
  vector<vector<int>> nodes;
  tochk.push(mp(0,0));
  int depth[n];
  depth[0]=0;
  ll dp[n][2];//white,black
  bool found[n]={0};
  found[0]=1;
  nodes.pb({0});
  while(!tochk.empty()){
      for(int i=0;i<edge[tochk.front().first].size();i++){
       if(!found[edge[tochk.front().first][i]]){
       found[edge[tochk.front().first][i]]=1;
       tochk.push(mp(edge[tochk.front().first][i],tochk.front().second+1));
       if(tochk.front().second+1>=nodes.size()){
           nodes.pb({edge[tochk.front().first][i]});
       }
       else{
           nodes[nodes.size()-1].pb(edge[tochk.front().first][i]);
       }
       depth[edge[tochk.front().first][i]]=tochk.front().second+1;
      }
      }
      tochk.pop();
  }
  for(int i=0;i<nodes[nodes.size()-1].size();i++){
      dp[nodes[nodes.size()-1][i]][0]=1;
      dp[nodes[nodes.size()-1][i]][1]=1;
  }
  for(int i=nodes.size()-2;i>=0;i--){
      for(int j=0;j<nodes[i].size();j++){
          dp[nodes[i][j]][0]=1;
          dp[nodes[i][j]][1]=1;
          for(int k=0;k<edge[nodes[i][j]].size();k++){
              if(depth[edge[nodes[i][j]][k]]==i+1){
                  dp[nodes[i][j]][0]*=dp[edge[nodes[i][j]][k]][0]+dp[edge[nodes[i][j]][k]][1];
                  dp[nodes[i][j]][1]*=dp[edge[nodes[i][j]][k]][0];
                  dp[nodes[i][j]][0]%=p;
                  dp[nodes[i][j]][1]%=p;
              }
          }
      }
  }
  
  return (dp[0][0]+dp[0][1])%p;
}
ll solvebad(){

}
int output(){
   
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//cin >>t;
	t=1;
    srand(time(0));
	while(t--){
	   init();
	   if(debugging){
	       if(outputcheck){
	          if(solve()!=solvebad()){//checking for random input
	             output();
	          }
	       }
	       if(timecheck){
	           auto start=high_resolution_clock::now();
	           solve();
	           auto stop=high_resolution_clock::now();
	           auto duration = duration_cast<microseconds>(stop - start);
	           cout<<duration.count()<<" Fast\n";
	           start=high_resolution_clock::now();
	           solvebad();
	           stop=high_resolution_clock::now();
	           duration = duration_cast<microseconds>(stop - start);
	           cout<<duration.count()<<" Slow\n";
	       }
	   }
	   else{
	       cout<<solve()<<"\n";//solving it correctly
	   }
	}
}

Measured memory_bytes: 12848