using System;

namespace ITP1_9
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine();
            int c = 0;
            while(true)
            {
                string _a = Console.ReadLine();
                if(_a == "END_OF_TEXT") break;
                c += (_a.Length - _a.ToLower().Replace(w, "").Length) / w.Length;
            }
            Console.WriteLine("{0}", c);
        }
    }
}