require 'set'
loop do
  n = gets.to_i
  break if  n == 0
  hash = Hash.new{|h,k|h[k]=Array.new}
  input = Array.new
  init = ""
  n.times do |i|
    input[i]=gets.chomp.chop
    tag,members = input[i].split(":")
    if i==0
      init = tag
    end
    hash[tag]=members.split(",")
  end
  q = hash[init]
  ans =0
  set = Set.new
  loop do
    if q.empty?
      break
    end
    elem = q.shift
    unless hash.has_key?(elem)
      unless set.include?(elem)
        ans+=1
      end
      set.add(elem)
      next
    end
    hash[elem].each do |e|
      q.push(e)
    end
  end
  puts ans
end