using System;
using System.Threading.Channels;

namespace SIO_Stablo
{
    class Program
    {
        static void ulaz(out int a, out int b, out char c)
        {
            string[] s = Console.ReadLine().Split();
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            c = char.Parse(s[2]);
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int u, v;
            char c;
            int br = 0;
            for (int i = 1; i <= n - 1; i++)
            {
                ulaz(out u, out v, out c);
                if (u >= 1 && u < v && v <= n)
                {
                    br++;
                }
            }
            Console.WriteLine(br);
        }
    }
}