require 'set'

def f(groups, g_name)
	s = Set.new
	groups[g_name].each{|m|
		if groups[m]
			s += f(groups, m)
		else
			s << m
		end
	}
	s
end

loop {
	n = gets.to_i
	break if n == 0
	groups = {}
	n.times {
		name, *members = gets.chomp.split(/[:,.]/)
		groups[name] = members
	}
	p f(groups, groups.to_a[0][0]).size
}