#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <string>

using namespace std;

int n;
map<string, vector<string> > mp;
string q;
set<string> ans, used;

void dfs(string v)
{
  used.insert(v);
  if(mp[v].size() == 0){
    ans.insert(v);
    return;
  }
  for(auto it = mp[v].begin(); it != mp[v].end(); it++){
    if(!used.count(*it)) dfs(*it);
  }
}

int main(void)
{
  while(1){
    cin >> n;
    if(n == 0) break;

    mp.clear();

    string s;
    string name; int p;
    for(int i = 0; i < n; i++){
      cin >> s;
      for(int j = 0; j < s.size(); j++){
        if(s[j] == ':'){
          name = s.substr(0, j);
          p = j;
          break;
        }
      }
      string t;
      for(int j = p+1; j < s.size(); j++){
        if(s[j] >= 'a' && s[j] <= 'z') t += s[j];
        else mp[name].push_back(t), t = "";
      }
      if(i == 0) q = name;
    }

    /*for(auto it = mp.begin(); it != mp.end(); it++){
      cout << it->first << " : ";
      for(int i = 0; i < it->second.size(); i++) cout << it->second[i] << " "; cout << endl;
    }*/

    ans.clear(), used.clear();
    dfs(q);
    cout << ans.size() << endl;
  }

  return 0;
}

