using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] nr = new int[n+1];
            int[] nk = new int[n+1];
            for (int i = 1; i <= n; i++)
            {
                string s;
                s = Console.ReadLine();
                string[] words = s.Split(' ');
                foreach (var word in words)
                {
                    nr[i] = int.Parse(words[0]);
                    nk[i] = int.Parse(words[1]);
                }
            }
            int[]b = new int[n+1];
            int br = 0;
            for (int i = 1; i <=n; i++)
            {
                for (int j = 1; j <=n; j++)
                {
                    if (nr[i] == j) b[i]++;
                    if (nk[i] == j) b[i]++;
                }
                if (b[i] > 2) br++;                
            }
            if (br == 0) Console.WriteLine(br);

            

        }
    }
}