#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<string>
#define REP(it,end) for (int it = 1; it <= (end); it++)
#define FOR(it,begin,end) for (int it = (begin); it <= (end); it++)
#define ROF(it,begin,end) for (int it = (begin); it >= (end); it--)
using namespace std;
map<string,int> toi;
vector<int> mem[201];
string s,tmp,stmp;
void getans(int u)
{
	int i,j,v;
	for(i=0;i<(int)mem[u].size();i++)
	{
		v=mem[u][i];
		//cout <<"u:"<<u<<" v:"<<v<<endl;system("pause");
		if(mem[v].size()>0)
		{
			mem[u].erase(mem[u].begin()+i);
			//for(i=0;i<(int)mem[u].size();i++)cout <<mem[0][i]<<" ";cout <<endl;
			getans(v);
			for(j=0;j<(int)mem[v].size();j++)
				mem[u].push_back(mem[v][j]);
			//for(i=0;i<(int)mem[u].size();i++)cout <<mem[0][i]<<" ";cout <<endl;
		}
	}
	sort(mem[u].begin(),mem[u].end());
	mem[u].resize(unique(mem[u].begin(),mem[u].end())-mem[u].begin());
}
int main()
{
	int idx,n,slen,i,j;
	while(cin>>n&&n!=0)
	{
		idx=0;toi.clear();
		for(i=0;i<201;i++)mem[i].clear();
		getline(cin,s);
		for(i=0;i<n;i++)
		{
			getline(cin,s);
			slen=s.size();
			tmp.clear();
			for(j=0;j<slen&&s[j]!=':';j++)
				tmp+=s[j];
			if(toi.find(tmp)==toi.end())toi[tmp]=idx++;
			stmp.clear();
			//cout <<tmp<<endl;
			for(j++;j<slen;j++)
			{
				if(s[j]==','||s[j]=='.')
				{
					//cout <<stmp<<endl;
					if(toi.find(stmp)==toi.end())toi[stmp]=idx++;
					mem[toi[tmp]].push_back(toi[stmp]);
					stmp.clear();
				}
				else stmp+=s[j];
			}
		}
		//map<string,int>::iterator it;for(it=toi.begin();it!=toi.end();it++)cout <<(it->first)<<" "<<(it->second)<<endl;
		getans(0);
		//for(i=0;i<(int)mem[0].size();i++)cout <<mem[0][i]<<" ";cout <<endl;
		cout <<mem[0].size()<<endl;
	}
	return 0;
}