#include<iostream>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;

int main()
{
  map<string,vector<string> > M;
  map<string,bool> Mp;
  int n;
  string s;
  string f;

  while(1){
    cin>>n;
    if(n==0)break;
    M.clear();
    Mp.clear();
    for(int i=0;i<n;i++){
      cin>>s;
      vector<string> V;
      int start=0;
      for(int j=0;j<s.length();j++){
	if(s[j]==':' || s[j]==',' || s[j]=='.'){
	  V.push_back(s.substr(start,j-start));
	  start=j+1;
	}
	if(s[j]==':' && i==0)f=s.substr(0,j);
      }
      s=V[0];
      V.erase(V.begin());
      M[s]=V;
    }

    queue<string> Q;
    set<string> set;
    Q.push(f);
    Mp[f]=true;
    while(!Q.empty()){
      string S=Q.front();
      Q.pop();
      vector<string> V=M[S];

      for(int i=0;i<V.size();i++){
	if(M[V[i]].empty())set.insert(V[i]);
	else {
	  if(Mp[V[i]])continue;
	  Mp[V[i]]=true;
	  Q.push(V[i]);
	}

      }
    }
    cout<<set.size()<<endl;
  }
  return 0;
}