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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int lala=0;
            for(int i = 0; i < n-1; i++)
            {
                string[] fr = Console.ReadLine().Split();
                int a = int.Parse(fr[0]);
                int b = int.Parse(fr[1]);
                if((Math.Abs(a-b))!=1)
                {
                    lala++;
                }
            }
            if(lala==0)
            {
                if(n%2==0)
                    Console.WriteLine(n-3);
                else
                    Console.WriteLine(n-2);
            }
            Console.ReadKey();
        }
    }
}