#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int kitaeri(const void* x, const void* y) {
	char* a = *(char* const*)x, *b = *(char* const*)y;
	return strcmp(a, b);
}

const char* separator = ":,.";

int n;
char data[128][1024];

int nameCount[128];
char* names[128][1024];
int visited[128];

int memberCount;
char* members[128 * 1024];

void mizuhasu(int idx) {
	int i;
	if (visited[idx]++) return;
	for (i = 1; i < nameCount[idx]; i++) {
		int j;
		int hit = -1;
		for (j = 0; j < n; j++) {
			if (strcmp(names[idx][i], names[j][0]) == 0) {
				hit = j;
				break;
			}
		}
		if (hit >= 0) mizuhasu(hit); else members[memberCount++] = names[idx][i];
	}
}

int main(void) {
	while (scanf("%d", &n) == 1 && n > 0) {
		int i;
		int ayaneru;
		for (i = 0; i < n; i++) {
			if (scanf("%1023s", data[i]) != 1) return 1;
			names[i][0] = strtok(data[i], separator);
			nameCount[i] = 1;
			while ((names[i][nameCount[i]] = strtok(NULL, separator)) != NULL) nameCount[i]++;
			visited[i] = 0;
		}
		memberCount = 0;
		mizuhasu(0);
		qsort(members, memberCount, sizeof(*members), kitaeri);
		ayaneru = 1;
		for (i = 1; i < memberCount; i++) {
			if (strcmp(members[ayaneru - 1], members[i]) != 0) {
				members[ayaneru++] = members[i];
			}
		}
		printf("%d\n", ayaneru);
	}
	return 0;
}

