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

void dfs(vector<vector<int> > &adj, vector<bool> &used, int node, set<int> dame, int &ans){

    //cout << node << endl;
    used[node] = true;
    if(dame.find(node) == dame.end()) ans++;

    for(auto x : adj[node]){

        if(!used[x]){
            dfs(adj, used, x, dame, ans);
        }
    }

}

//みつよし作
vector<string> split(string s){
    vector<string> ret;
    int idx = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == ':' || s[i] == ',' || s[i] == '.'){
            ret.push_back(s.substr(idx, i - idx));
            idx = i + 1;
        }
    }
    return ret;
}
 
int main(){


    while(1){
        int n; cin >> n;
        if(!n) break;

        int V = 0;
        map<string, int> str_to_i;
        set<int> dame;
        vector<vector<int> > adj(10000);
        for(int i = 0; i < n; i++){
            string s; cin >> s;
            vector<string> vec = split(s);
            //cout << "V = " << V << endl;
            int u;
            if(str_to_i.find(vec[0]) == str_to_i.end()){
                u = V;
                str_to_i[vec[0]] = V;
                V++;
            }else{
                u = str_to_i[vec[0]];
            }
            //cout << "u = " << u << endl;
            dame.insert(u);

            for(int i = 1; i < (int)vec.size(); i++){
                int v;
                //cout << "hoge" << endl;
                if(str_to_i.find(vec[i]) == str_to_i.end()){
                    v = V;
                    str_to_i[vec[i]] = V;
                    V++;
                }else{
                    v = str_to_i[vec[i]];
                }

                //cout << "huga" << endl;
                //cout << "u = " << u << ", v =  " << v << endl;
                adj[u].push_back(v);
                
            }
        }
        
        //cout << " V = " <<  V << endl;
        vector<bool> used(V, false);
        int ans = 0;
        dfs(adj, used, 0, dame, ans);
        cout << ans << endl;
        
    }

    return 0;
}
