require 'set'
loop do
    n = gets.to_i
    break if n == 0
    g = n.times.map{gets.chomp}
    h = Hash.new(Array.new)
    f = ""
    g.each_with_index do |s,i|
        s = s.gsub("\.","").split(":")
        h[s[0]] = s[1].split(",")
        f = s[0] if i == 0
    end
    t = h.to_a[0][0]
    ans = Set.new
    a = h[t]
    while !a.empty?
        a2 = Set.new
        a.each do |m|
            if h.has_key?(m)
                h[m].each do |mm|
                    a2.add(mm)
                end
            else
                ans.add(m)
            end
        end
        a = a2.to_a
    end
    p ans.size
end