#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; } vector> T; vector> dp; void dfs(ll u, ll p){ if((ll)T[u].size()==1 && u != 0){ dp[u][2] = 1; return; } ll l_cnt = 0; for(ll v : T[u]){ if(v == p) continue; dfs(v, u); if((ll)T[v].size() == 1) l_cnt++; } if(l_cnt >= 3){ cout << 0 << endl; exit(0); }else if(l_cnt == 2){ dp[u][0] = 1; for(ll v : T[u]){ if(v == p) continue; if((ll)T[v].size()==1) continue; dp[u][0]*=(dp[v][0]+dp[v][1])%MOD2; dp[u][0]%=MOD2; } }else if(l_cnt == 1){ ll all_cut = 1; for(ll v : T[u]){ if(v == p) continue; if((ll)T[v].size()==1) continue; all_cut*=(dp[v][0]+dp[v][1])%MOD2; all_cut%=MOD2; } dp[u][1] = all_cut; ll cut1 = 0; for(ll v : T[u]){ if(v == p) continue; if((ll)T[v].size()==1) continue; ll tmp = pow_mod((dp[v][0]+dp[v][1])%MOD2, MOD2-2, MOD2); tmp*=all_cut; tmp%=MOD2; tmp*=(dp[v][1]+dp[v][2])%MOD2; cut1+=tmp%MOD2; cut1%=MOD2; } dp[u][0]=cut1; }else{ ll all_cut = 1; for(ll v : T[u]){ if(v == p) continue; all_cut*=(dp[v][0]+dp[v][1])%MOD2; all_cut%=MOD2; } dp[u][2] = all_cut; ll cut1 = 0; for(ll v : T[u]){ if(v == p) continue; ll tmp = pow_mod((dp[v][0]+dp[v][1])%MOD2, MOD2-2, MOD2); tmp*=all_cut; tmp%=MOD2; tmp*=(dp[v][1]+dp[v][2])%MOD2; cut1+=tmp%MOD2; cut1%=MOD2; } dp[u][1]=cut1; ll cut2 = 0; ll child = 0; for(ll v : T[u]){ if(v == p) continue; child++; } if(child == 1) return; vector sum(child+1, 0); ll now = 1; for(ll v : T[u]){ if(v == p) continue; sum[now] = pow_mod((dp[v][0]+dp[v][1])%MOD2, MOD2-2, MOD2); sum[now] *= (dp[v][1]+dp[v][2])%MOD2; sum[now] += sum[now-1]; sum[now] %= MOD2; now++; } now = 1; for(ll v : T[u]){ if(v == p) continue; ll sum2 = (sum.back() - sum[now] + MOD2)%MOD2; now++; sum2 *= (dp[v][1]+dp[v][2])%MOD2; sum2%=MOD2; sum2 *= pow_mod((dp[v][0]+dp[v][1])%MOD2, MOD2-2, MOD2); sum2 %= MOD2; cut2+=sum2; cut2%=MOD2; } cut2 *= all_cut; cut2 %= MOD2; dp[u][0] = cut2; } return; } int main(){ 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); //rep(i, n) cout << i+1 << " : " << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl; cout << (dp[0][0]+dp[0][1])%MOD2 << endl; }