#include<iostream>
#include<vector>
#include<map>

using namespace std;

map<string,vector<string> > M;
map<string,bool> counted;

int N,ans;
string wanted;

void init(){
  M.clear();
  counted.clear();
  ans = 0;
}

void input(){
  
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    
    vector<string> V;
    string tmp = "";
    string gname;

    for(int j = 0; j < s.length(); j++){
      if(s[j] == ':'){
	gname = tmp;
	tmp = "";
	if(i == 0) wanted = gname;
      }else if(s[j] == ',' || s[j] == '.'){
	V.push_back(tmp);
	tmp = "";
      }else tmp += s[j];
    }
    
    M[gname] = V;
  }
}

void solve(string s){

  vector<string> V = M[s];
  
  counted[s] = true;

  for(int i = 0; i < V.size(); i++){
    if(M[V[i]].size() > 0 && !counted[V[i]]) solve(V[i]);
    else if(counted[V[i]] == false){
      counted[V[i]] = true;
      ans++;
    }
  }
}


int main(){

  while(cin >> N  && N){
    init();
    input();
    solve(wanted);
    cout << ans << endl;
  }
  
  return 0;
}