using System;

namespace ConsoleApp3
{
    class Program
    {
        struct red {
            public int U;
            public int V;
            public char slovo;
        }
        static red ucitajred()
        {
            red r = new red();
            String[] elementi = Console.ReadLine().Split();
            r.U = Convert.ToInt32(elementi[0]);
            r.V = Convert.ToInt32(elementi[1]);
            r.slovo = Convert.ToChar(elementi[2]);
            return r;
        }
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int a=0, b=0, g=0;
            for (int i = 0; i < n-1; i++)
            {
                red c = ucitajred();
                if (c.slovo =='S')
                {
                    a = Convert.ToInt32(c.U);
                }
                else if (c.slovo == 'O')
                {
                    b = Convert.ToInt32(c.V);
                }
                else
                {
                    g--;
                }
                if (1<=a && a<b && b<=n)
                {
                    g++;
                }
            }
            Console.WriteLine(g.ToString());
        }
    }
}