// -------------------------Solution by Stormgamming------------------------- // /* Author : Nguyen Ngoc Hung, Ngo Gia Tu high school */ /* Tips: 1.int? long long? 2.don't submit wrong answer 3.figure out logic first, then start writing please 4.know about the range 5.check if you have to input t or not 6.modulo of negative numbers is not a%b, it is a%b + abs(b) ┏━━┓┏━━┓┏━━┓┏━━┓ ┗━┓┃┃┏┓┃┗━┓┃┗━┓┃ ┏━┛┃┃┃┃┃┏━┛┃┏━┛┃ ┃┗━┓┃┗┛┃┃┗━┓┃┗━┓ ┗━━┛┗━━┛┗━━┛┗━━┛ */ #include using namespace std; /***PRAGMA***/ // #pragma GCC target ("avx2") // #pragma GCC optimization ("O2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") // #pragma GCC target ("sse4") /***TEMPLATE***/ #define DEBUG(X) {auto _X=(X); cerr << "L" << __LINE__ << ": " << #X << " = " << (_X) << endl;} #define __Storgamming__ signed main() #define count_bit(mask) __builtin_popcountll(mask) #define repdis(i,be,en,j) for(int i = (be); i<=(en); i+=j) #define rep(i,be,en) for(int i = (be); i<=(en); i++) #define repd(i,be,en) for(int i = (be); i>=(en); i--) #define trav(a,x) for(auto& a:x) #define on(i,m) (m|=(1LL< #define pb push_back #define eb emplace_back #define inf 0x3f3f3f3f #define mp make_pair #define pii pair #define ull unsigned long long #define ll long long #define ld long double #define int long long #define fi first #define se second #define endl "\n" #define bit(i,j) ((i>>j)&1ll) #define mask(i) (1ll< void __print(const pair &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef LOCAL #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif /***Common Functions***/ template bool ckmin(T& a, const T& b){return a>b?a=b,1:0;} template bool ckmax(T& a, const T& b){return avoid add_mod(num_t& a, const long long& b, const int& m){a=(a+b)%m;if(a>=m)a-=m;if(a<0)a+=m;} templatenum_t gcd(num_t lhs, num_t rhs) {return !lhs?rhs:gcd(rhs%lhs,lhs);} templatenum_t pw(num_t n, num_t k, const num_t& mod){if(k==-1)k=mod-2;num_t res=1;for(; k>0;k>>=1){if(k&1)res=1ll*res*n%mod;n=1ll*n*n%mod;}return res%mod;} const int N = (int)1e6+1; const int SIZE = (int)1e6+10; const int maxn = (int)1e5+1; const int MOD = (int)1e9+7; const int oo = (int)1e18+7; const int base = (int)311; const ld PI = 4*atan((ld)1); /***End of Template***/ int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; vector> a; vector f; void dfs(int u, int dad){ bool ok = false; trav(v,a[u]){ if(v!=dad){ dfs(v,u); if(f[v]==true){ ok = true; } } } if(ok==false){ f[u] = true; } } void solve(){ int n,u,v,res = 0; cin >> n; a = vector>(n+2,vector()); f = vector(n+2,false); rep(i,2,n){ cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } dfs(1,-1); rep(i,1,n){ if(f[i]==true){ res++; } } cout << res; } __Storgamming__{ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin.exceptions(ios::badbit | ios::failbit); // freopen("A.inp", "r", stdin); // freopen("A.out", "w", stdout); int test = 1; while(test--){ solve(); } return 0; } /** * ʕ•ᴥ•ʔ * [storgamming] * U U */