/*
TASK:man
LANG:C++
*/
#include<iostream>
#include<vector>
#include<string>

using namespace std;

bool a[15000][15000]; 
bool used[15000];
int max1;
bool check=true;
void DFS(int p, int q)
{
    int k;
    used[p]=1;
    for(k=0;k<=max1;k++)
        if(a[p][k] && !used[k])
        {
            if(k==q)
            {
                check=false;
            }
            DFS(k, q);
        } 
}
int main()
{
    int M, p, q, i, ans=0;
    cin >> M;
    for(i=0;i<M;i++)
    {
        cin >> p >> q;
        if(p>max1)
            max1=p;
        if(q>max1)
            max1=q;
        for(int j=0;j<max1;j++)
            used[j]=0;
        DFS(p, q);
        if(check)
        {
            ans++;
            a[p][q]=1;
            a[q][p]=1;
        }
        else check=true;
     }
     cout << ans << endl;
}
