#include #define INF 2147483647 #define INF_LL 9223372036854775807 #define MOD 1000000007 using namespace std; typedef long long int ll; typedef unsigned long long int ull; int main() { int N; cin >> N; vector mat(N, 0); for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; mat[a]++; mat[b]; } int ans = 0; for (int i = 0; i < N; i++) { if (mat[i] > 2)ans += mat[i] - 2; } cout << ans << endl; }