#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n;
    const int N=4e5;
    vector<unordered_set<int> > gr(N+1);
    vpr vec;
    for (int i = 0; i < n; ++i)
    {
        int a,b;cin>>a>>b;
        vec.pb({a,b});
        gr[a].insert(i);
        gr[b].insert(i);
    }
    queue<int>que;
    for (int i = 1; i <= N; ++i)
    {
        if(sz(gr[i])==1)
        {
            que.push(i);
        }
    }
    int ans=0;
    while(!que.empty())
    {
        int u=que.front();
        que.pop();
        if(sz(gr[u])!=1)
            continue;
        ans++;
        int i=*gr[u].begin();
        gr[u].erase(gr[u].begin());
        int u1=vec[i].first^vec[i].second^u;
        if(u1 !=u)
        {
            gr[u1].erase(i);
            if(sz(gr[u1]) == 1)
                que.push(u1);
        }
    }
    for (int i = 1; i <= N; ++i)
    {
        if(sz(gr[i]))
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<bitset>
//#include<unordered_map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
//#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'a')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
//const double pi=acos(-1);
const int maxn=1000010;
//const ll Mod=1000000007;
const ll Mod=998244353;

int c[maxn];
vector<int>g[maxn];

int head[maxn],d[maxn];
int tot,n,m;
struct node
{
    int v,nxt;
    ll w;
}e[maxn<<1];

void add(int u,int v,ll c)
{
    e[tot].v=v;
    e[tot].w=c;
    e[tot].nxt=head[u];
    head[u]=tot++;
    e[tot].v=u;
    e[tot].w=0ll;           //为0！！！
    e[tot].nxt=head[v];
    head[v]=tot++;
}

int bfs(int s,int t)
{
    queue<int>q;
    memset(d,-1,sizeof(d));
    d[s]=0;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        if(u==t)
            return 1;
        for(int i=head[u];i!=-1;i=e[i].nxt)
        {
            int v=e[i].v;
            if(d[v]==-1&&e[i].w>0)
            {
                d[v]=d[u]+1;
                q.push(v);
            }
        }
    }
    return 0;
}


ll dfs(int u,ll flow,int t)
{
    if(u==t)
        return flow;
    ll sum=0;
    for(int i=head[u];i!=-1;i=e[i].nxt)
    {
        int v=e[i].v;
        ll w=e[i].w;
        if(w>0&&d[v]==d[u]+1)
        {
            ll tmp=dfs(v,min(1ll*flow-sum,e[i].w),t);
            e[i].w-=1ll*tmp;
            e[i^1].w+=1ll*tmp;
            sum+=1ll*tmp;
            if(sum==flow)
                return sum;
        }
    }
    if(sum==0)
        d[u]=0;
    return sum;
}

ll dinic(int s,int t)
{
    ll total=0;
    while(bfs(s,t))
        total+=1ll*dfs(s,2e14,t);
    return total;
}

bool vvs[maxn];

int main()
{
    sync;
    memset(head,-1,sizeof(head));
    int u,v;
    int st,ed;
    tot=0;
    st=0,ed=400001;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>u>>v;
        vvs[u]=1;
        vvs[v]=1;
        add(st,i+ed,1);
        add(i+ed,u,1);
        add(i+ed,v,1);
    }
    for(int i=1;i<=400000;i++)
    {
        if(vvs[i])
        add(i,ed,1);
    }
    
    cout<<dinic(st,ed)<<endl;
    
    return 0;
}


