package com.thinker.bishi.xiaomi;

import java.util.Scanner;

/**
 * @author lzh
 */
public class ShuGao {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int len = Integer.parseInt(in.nextLine());
        int[][] arr = new int[len][len];
        for(int i=0;i<len;i++){
            for(int j=0;j<len;j++){
                arr[i][j] = 0;
            }
        }
        arr[0][0] = 1;
        int k=1;
        while (k<len){
            String[] tmp = in.nextLine().split(" ");
            int i = Integer.parseInt(tmp[0])+1;
            int j = Integer.parseInt(tmp[1]);
            arr[i][j] = 1;
            k++;
        }
        k = 0;
        for(int i=0;i<len;i++){
            int count = 0;
            for(int j=0;j<len;j++){
                if(arr[i][j] == 1){
                    k++;
                    break;
                }else {
                    count ++;
                }
            }
            if(count == len){
                break;
            }
        }
        System.out.println(k);
    }
}
