#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 = 998244353; const ll INF = 1LL << 60; const ll MAX_N = 2e5; ll pow_mod(ll x, ll n, ll mod){ ll ret = 1; while(n > 0){ if(n & 1) ret = (ret*x)%mod; x = x*x%mod; n >>=1; } return ret; } ll mod = MOD2; vector> T; vector> dp; void dfs(ll u, ll p){ for(ll v : T[u]) if(v != p) dfs(v, u); ll zero_cnt = 0; for(ll v : T[u]) if(v != p) if((dp[v][0]+dp[v][1])==0) zero_cnt++; if(zero_cnt>=3){ cout << 0 << endl; exit(0); } if(zero_cnt == 0){ ll mul = 1; for(ll v : T[u]) if(v != p){ mul = (mul * (dp[v][0]+dp[v][1]))%mod; } //dp[u][0]を計算 ll sum0 = 0; for(ll v : T[u]) if(v != p){ ll tmp = ((dp[v][0]+dp[v][2])%mod*pow_mod((dp[v][0]+dp[v][1])%mod, mod-2, mod))%mod; sum0 = (sum0 + tmp)%mod; } dp[u][0] = (mul*sum0)%mod; //dp[u][1]を計算 ll sum1 = 0; ll lsum = 0; for(ll v : T[u]) if(v != p){ ll tmp = ((dp[v][0]+dp[v][2])%mod*pow_mod((dp[v][0]+dp[v][1])%mod, mod-2, mod))%mod; sum1 = (sum1 + (tmp*lsum)%mod)%mod; lsum = (lsum + tmp)%mod; } dp[u][1] = (mul*sum1)%mod; //dp[u][2]を計算 dp[u][2] = mul; }else if(zero_cnt == 1){ ll mul = 1; for(ll v : T[u]) if(v != p) if((dp[v][0]+dp[v][1])!= 0){ mul = (mul * (dp[v][0]+dp[v][1]))%mod; } ll a; for(ll v : T[u]) if(v != p) if((dp[v][0]+dp[v][1])==0) a=v; //dp[u][0]を計算 dp[u][0] = (mul*dp[a][2])%mod; //dp[u][1]を計算 for(ll v : T[u]) if(v != p) if((dp[v][0]+dp[v][1])!=0){ ll tmp = (dp[a][2]*(dp[v][0]+dp[v][2]))%mod; tmp = (tmp * pow_mod((dp[v][0]+dp[v][1])%mod, mod-2, mod))%mod; dp[u][1] = (dp[u][1]+tmp)%mod; } dp[u][1] = (dp[u][1]*mul)%mod; }else if(zero_cnt == 2){ ll mul = 1; for(ll v : T[u]) if(v != p) if((dp[v][0]+dp[v][1])!= 0){ mul = (mul * (dp[v][0]+dp[v][1]))%mod; } ll a=-1, b=-1; for(ll v : T[u]) if(v != p) if((dp[v][0]+dp[v][1])==0){ if(a==-1){ a=v; }else{ b=v; } } //dp[u][1]を計算 dp[u][1] = ((dp[a][2]*dp[b][2])%mod * mul)%mod; } return; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n; cin >> n; T.resize(n); dp.resize(n, vector(3, 0)); rep(i, n-1){ ll u, v; cin >> u >> v; u--; v--; T[u].pb(v); T[v].pb(u); } dfs(0, -1); cout << (dp[0][0]+dp[0][1])%mod << endl; }