import java.io.*;
import java.util.*;

public class Main{
    String dataset[], groupAndMember[][], splitData[], splitMember[];
    ArrayList<String> member = new ArrayList<String>();
    boolean visitGroup[];

    private void run() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        HashSet<String> hashSet = new HashSet<String>();
        int input;

        while(true){
            input = Integer.parseInt(in.readLine());
            if(input == 0) return;
            dataset = new String[input];     // ?´?????????????
            visitGroup = new boolean[input]; // ?¢????????????°?????????
            groupAndMember = new String[input][11];  // [0]?????°?????????[1]-[10]?????????????????\???

            for(int i = 0; i < input; i++){
                dataset[i] = in.readLine();
            }

            for(int i = 0; i < input; i++){
                visitGroup[i] = false;
                splitData = dataset[i].split(":");    // ??°???????????¨?????????????????????
                groupAndMember[i][0] = splitData[0];  // ??°?????????????????£??\
                splitMember = splitData[1].split(",");// ?????????????????????
                // ??????????????£??\
                for(int j = 0; j < splitMember.length; j++){
                    // ???????????????????????? "." ??????????????§???????????????
                    if(j != splitMember.length-1){
                        groupAndMember[i][j+1] = splitMember[j];
                    } else{
                        groupAndMember[i][j+1] = splitMember[j].replace(".", "");
                    }
                }
            }
            this.check(0);
            hashSet.addAll(member); // ??????????¶????
            System.out.println(hashSet.size()); // ?????°?????¨???
            // ?????????????????????????????????
            hashSet.clear();
            member.clear();
        }
    }

    // ??°?????????????????????????????????????´???????
    // ??°?????????????????°??????????????????????????°?????°??????????????????
    private void check(int row){
        if(visitGroup[row]) return; // ?????§???????????°?????????????????????
        visitGroup[row] = true;
        boolean groupFlag;
        String group = groupAndMember[row][0];

        for(int i = 1; i < groupAndMember[row].length; i++){
            groupFlag = false;
            if(groupAndMember[row][i] == null) break; // ??°????????????????????°???10?????????????????´?????????????????§null?????§??????
            for(int j = 1; j < dataset.length; j++){
                // ??°??????????????????????????°?????????????????£?????´???????????°??????????????????
                // groupAndMember????¬¬?????????????´???? 0 ?????´????????°??????????????¨??????
                if(groupAndMember[row][i].equals(groupAndMember[j][0])){
                    groupFlag = true;
                    this.check(j);
                    break;
                }
            }
            // ??°??????????????§????????£?????´??????????????????????????????????????????????´?
            if(!groupFlag){
                member.add(groupAndMember[row][i]);
            }
        }
    }

    public static void main(String args[]) throws IOException{
        Main app = new Main();
        app.run();
    }
}

Measured memory_bytes: 33684