// Slower C++ solution:
//#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

	   }

	}

}

// Faster C++ solution for the same problem (measured speedup: 3.484023521769403x):
#include <iostream>

#include <bits/stdc++.h>

#define mp make_pair

#define pb push_back

using namespace std;

using ll = long long int;

const int p = 1e9 + 7;

void solve(){

    int n;

    cin>>n;

    vector<vector<int>> adj(n);

    for(int i=0;i<n-1;i++){

        int u,v;

        cin>>u>>v;

        --u;--v;

        adj[u].pb(v);

        adj[v].pb(u);

    }

    vector<ll> dpblack(n, 1);

    vector<ll> dpwhite(n, 1);

    function<void(int,int)> dfs = [&](int u, int par){

        ll &w = dpwhite[u];

        ll &b = dpblack[u];

        for(const auto &e : adj[u]){

            if(e==par){

                continue;

            }

            dfs(e, u);

            w*=(dpblack[e] + dpwhite[e]);

            b*=dpwhite[e];

            w%=p;

            b%=p;

        }

    };

    dfs(0,-1);

    cout<<(dpblack[0] + dpwhite[0])%p;

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    solve();

}