var input = '';
var line = 0;
var groupname;
var group = {};
var membership = {};

process.stdin.on('data', function (chunk) {
    input += chunk;
});
process.stdin.on('end', function () {
    input = input.trim().split(/\s+/);
    solve();
});

function solve() {
    while (true) {
        var n = input[line++];
        if (n == 0)
            break;
        for (var i = 0; i < n; i++) {
            var nested = input[line++].slice(0, -1).split(':');
            group[nested[0]] = nested[1].split(",");
            if (i === 0) {
                groupname = nested[0];
            }
        }
        dfs(groupname);
        var answer = 0;
        for (var i in membership) {
            ++answer;
        }
        console.log(answer);

        group = {};
        membership = {};
    }
}

function dfs(groupname) {
    var member = group[groupname];
    group[groupname] = [];
    for (var i = 0; i < member.length; i++) {
        element = member[i];
        if (group[element] !== undefined) {
            dfs(element);
        } else {
            membership[element] = true;
        }
    }
}