var n;
var t;
var g = {};
var x = {};

function dfs(t, u){
	var gt = g[t];
	g[t] = [];
	rep(gt.length, function(i){
		v = gt[i];
		if(g[v] !== u && g[v].length > 0){
			dfs(v);
		}
		else{
			x[v] = true;
		}
	});
}

function main(){
	while(n = scan()){
		rep(n, function(i){
			var s = scan_string().slice(0, -1).split(':');
			g[s[0]] = s[1].split(',');
			if(i === 0){
				t = s[0];
			}
		});
		dfs(t);
		var ans = 0;
		for(var i in x){
			++ans;
		}
		print(ans);

		g = {};
		x = {};
	}
}

function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(){
	return +input[input_index++];
}

function scan_string(){
	return input[input_index++];
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/);
	main();
});