#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

void solve(int n) {
	string s,a;
	map<string, vector<string>> m;
	rep(i, n) {
		cin >> s;
		int k = 0;
		vector<string> ss;
		string stra;
		rep(j, s.size()) {
			if (s[j] == ':') {
				stra = s.substr(0,j);
				k = j + 1;
			}
			if (s[j] == ','|| s[j] == '.') {
				string str = s.substr(k, j-k);
				ss.push_back(str);
				//cout << str << endl;
				k = j + 1;
			}
		}
		if (i == 0)a = stra;
		m[stra] = ss;
	}
	bool sw = true;
	vector<string> ss=m[a];
	set<string> ans;
	rep(i, ss.size()) {
		ans.insert(ss[i]);
	}
	for (auto itr = ans.begin(); itr != ans.end(); itr++) {
		//cout << *itr << endl;
	}
	while (sw) {
		sw = false;
		for (auto itr = m.begin(); itr != m.end(); itr++) {
			//cout << itr->first << endl;
			if (ans.find(itr->first) != ans.end()) {
				sw = true;
				ans.erase(itr->first);
				vector<string> ss = m[itr->first];
				rep(i, ss.size()) {
					ans.insert(ss[i]);
				}
			}
		}
		//cout <<endl<<sw<< endl;
	}
	for (auto itr = ans.begin(); itr != ans.end(); itr++) {
		//cout << *itr << endl;
	}
	cout << ans.size() << endl;

}

int main() {
	int n;
	while (cin >> n, n) {
		solve(n);
	}
}
