#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    while(1)
    {
        int nb_equipes;
        cin>>nb_equipes;
        if(nb_equipes==0) break;
        map<string,vector<string> > m;
        string first = "";
        for(int c=0;c<nb_equipes;c++)
        {
            string s;
            cin>>s;
            string id = s.substr(0,s.find(':'));
            if(c==0) first = id;
            string reste = s.substr(s.find(':')+1);
            reste = reste.substr(0,reste.size()-1);
            stringstream ss(reste);
            string element;
            while(getline(ss,element,','))
            {
                m[id].push_back(element);
            }
        }
        vector<string> parcours;
        parcours.push_back(first);
        int res = 0;
        map<string,bool> visites;
        visites[first]=true;
        while(!parcours.empty())
        {
            string act = parcours.back();
            parcours.pop_back();
            if(m.find(act)==m.end())
            {
                res++;
            }
            for(int c=0;c<m[act].size();c++)
            {
                if(!visites[m[act][c]])
                {
                    visites[m[act][c]]=true;
                    parcours.push_back(m[act][c]);
                }
            }
        }
        cout<<res<<endl;
    }
}