#include<bits/stdc++.h>
using namespace std;

struct Group{
    set<string> chi;
};

map<string,Group> groups;



vector<string> split(string &x,char del){
    vector<string> res;
    string buf;
    for(int i=0;i<x.size();i++){
        if(x[i]==del) res.push_back(buf),buf.clear();
        else buf+=x[i];
    }
    if(!buf.empty()) res.push_back(buf);
    return res;
}
void dfs(string name){
    set<string> inserter;
    set<string> eraser;
    for(auto &cname:groups[name].chi){
        if(groups.count(cname)){
            dfs(cname);
            for(auto &e:groups[cname].chi) inserter.insert(e);
            eraser.insert(cname);

        }
        else{
            inserter.insert(cname);
        }
    }
    for(auto &e:inserter) groups[name].chi.insert(e);
    for(auto &e:eraser) groups[name].chi.erase(e);
    
    
}
int solve(){
    groups.clear();
    int n;
    cin>>n;
    if(n==0) return false;
    string name0;
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        int p=0;
        vector<string> tmp=split(str,':');
        string gname=tmp[0];
        if(i==0) name0=gname;
        vector<string> chils=split(tmp[1],',');
        chils.back().pop_back();
        for(int i=0;i<chils.size();i++){
            groups[gname].chi.insert(chils[i]);
        }
    }
    dfs(name0);
    cout<<groups[name0].chi.size()<<endl;
    return true;
}

int main(){
    while(solve());
    return 0;
}
