#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

void topological_sort(const vector<vector<int>>& G, vector<int>& ord)
{
   vector<int> num(G.size(),0);
   ord.resize(G.size());
   for (int i = 0; i < G.size(); i++) {
      for (int j = 0; j < G[i].size(); j++) {
         num[G[i][j]]++;
      }
   }
   stack<int> st;
   for(int i = 0; i < num.size(); i++) {
      if (num[i] == 0) {
         st.push(i);
      }
   }
   for (int k = 0; !st.empty(); k++) {
      int i = st.top(); st.pop();
      ord[k] = i;
      for(int j = 0; j < G[i].size(); j++) {
         num[G[i][j]]--;
         if (num[G[i][j]] == 0) {
            st.push(G[i][j]);
         }
      }
   }
}

void dfs(const V<V<int>>& g, V<V<int>>& G, int p, int v) {
   for (int i = 0; i < g[v].size(); i++) {
      int u = g[v][i];
      if (u == p) continue;
      G[v].push_back(u);
      dfs(g, G, v, u);
   }
}

template<int mod=MOD>
struct ModRing {
   int x;
   ModRing() : x(0) {}
   ModRing(int a) { x = ((a % mod) + mod) % mod; }

   bool operator==(const ModRing& a) const {
      return x == a.x;
   }
   bool operator!=(const ModRing& a) const {
      return x != a.x;
   }
   bool operator==(int a) const {
      return *this == ModRing(a);
   }
   bool operator!=(int a) const {
      return *this != ModRing(a);
   }
   ModRing& operator=(int a) {
      return *this = ModRing(a);
   }
   ModRing operator-() const {
      return ModRing((-x + mod) % mod);
   }
   ModRing& operator+=(const ModRing& a) {
      (x += a.x) %= mod;
      return *this;
   }
   ModRing& operator-=(const ModRing& a) {
      return *this += -a;
   }
   ModRing& operator*=(const ModRing& a) {
      (x *= a.x) %= mod;
      return *this;
   }
   const ModRing operator+(const ModRing& a) const {
      return ModRing(x) += a;
   }
   const ModRing operator-(const ModRing& a) const {
      return ModRing(x) -= a;
   }
   const ModRing operator*(const ModRing& a) const {
      return ModRing(x) *= a;
   }
   ModRing& operator+=(int a) {
      return *this += ModRing(a);
   }
   ModRing& operator-=(int a) {
      return *this -= ModRing(a);
   }
   ModRing& operator*=(int a) {
      return *this *= ModRing(a);
   }
   const ModRing operator+(int a) const {
      return ModRing(x) += a;
   }
   const ModRing operator-(int a) const {
      return ModRing(x) -= a;
   }
   const ModRing operator*(int a) const {
      return ModRing(x) *= a;
   }
   ModRing power(int n) const {
      ModRing tmp(x), res(1);
      while (n > 0) {
         if ((n & 1) == 1) res *= tmp;
         tmp *= tmp;
         n >>= 1;
      }
      return res;
   }
};
template<int mod>auto&operator<<(ostream&s,const ModRing<mod>&a){s<<a.x;return s;}

template<int mod=MOD>
struct FiniteField : ModRing<mod> {
   FiniteField() : ModRing<mod>() {}
   FiniteField(int a) : ModRing<mod>(a) {}
   FiniteField(const ModRing<mod>& a) : ModRing<mod>(a) {}

   FiniteField& operator=(int a) {
      return *this = ModRing<mod>::operator=(a);
   }
   FiniteField& operator+=(const FiniteField& a) {
      return *this = ModRing<mod>::operator+=(a);
   }
   FiniteField& operator-=(const FiniteField& a) {
      return *this = ModRing<mod>::operator-=(a);
   }
   FiniteField& operator*=(const FiniteField& a) {
      return *this = ModRing<mod>::operator*=(a);
   }
   FiniteField& operator+=(int a) {
      return *this = ModRing<mod>::operator+=(a);
   }
   FiniteField& operator-=(int a) {
      return *this = ModRing<mod>::operator-=(a);
   }
   FiniteField& operator*=(int a) {
      return *this = ModRing<mod>::operator*=(a);
   }

   FiniteField inverse() const {
      try { if (this->x == 0) throw "0 have no inverse"; }
      catch (const char* e) { cerr << e << endl; }
      return ModRing<mod>::power(mod-2);
   }
   FiniteField& operator/=(const FiniteField& a) {
      return *this *= a.inverse();
   }
   const FiniteField operator/(const FiniteField& a) const {
      return FiniteField(*this) /= a;
   }
   FiniteField& operator/=(int a) {
      return *this /= FiniteField(a);
   }
   const FiniteField operator/(int a) const {
      return FiniteField(*this) /= a;
   }
};

signed main()
{
   int n; cin >> n;
   V<V<int>> g(n);
   for (int i = 0; i < n-1; i++) {
      int x, y; cin >> x >> y;
      x--; y--;
      g[x].push_back(y);
      g[y].push_back(x);
   }
   V<V<int>> G(n);
   dfs(g, G, -1, 0);

   V<int> ord;
   topological_sort(G, ord);

   using GF = FiniteField<>;
   V<V<GF>> dp(2, V<GF>(n,1));
   for (int k = n-1; k >= 0; k--) {
      int v = ord[k];
      for (int i = 0; i < G[v].size(); i++) {
         int u = G[v][i];
         dp[0][v] *= dp[1][u];
         dp[1][v] *= dp[0][u] + dp[1][u];
      }
   }
   cout << dp[0][0] + dp[1][0] << endl;

   return 0;
}


Measured memory_bytes: 21232