#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
using namespace std;
int n;
map<string,vector<string> > tbl;
set<string> T;
map<string,bool> used;

void solve(string s){
  queue<string> Q;
  Q.push(s);
  while(Q.size()){
    string u = Q.front(); Q.pop();
    if(used[u]) continue;
    used[u]=true;
    if(tbl[u].empty()) T.insert(u);
    else
      for(string v : tbl[u])
	Q.push(v);
  }
}

int main(){
  while(cin>>n,n){
    tbl.clear();
    T.clear();
    used.clear();
    string key0="";
    for(int i=0;i<n;++i){
      string s;
      cin >> s;
      for(int j=0;j<s.length();++j)
	if(s[j]==':' || s[j]==',' || s[j]=='.') s[j]=' ';
      string key;
      stringstream ss;
      ss<<s;
      ss >> key;
      if(key0=="") key0=key;
      string tmp;
      while(ss >> tmp) tbl[key].push_back(tmp);
    }
    solve(key0);
    cout << T.size() << endl;
  }

  return 0;
}