import java.io.*;
import java.util.*;
import java.math.*;

public class contests_aa_wrong implements Runnable {

	public static void main(String[] args) {
		new Thread(new contests_aa_wrong()).start();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	@Override
	public void run() {
		// try {
		// Thread.sleep(20000);
		// } catch (InterruptedException e1) {
		// e1.printStackTrace();
		// }
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
		System.out.println((System.currentTimeMillis() - time) / 1000.0);
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(int x, int l, int r, String name) {
		myAssert(l <= x && x <= r, name + " not in bounds!!! " + x
				+ " not in [" + l + ".." + r + "]");
		return x;
	}

	String FNAME = "contests";

	class INode {
		public INode(String s) {
			content = new TreeMap<String, INode>();
			name = s;
		}

		TreeMap<String, INode> content;
		String name;
		boolean isFile;
		boolean isTests;
		boolean isProblem;
		boolean isContest;
	}

	private void solve() throws IOException {
		int n = inBounds(nextInt(), 1, 1000, "n");
		INode root = new INode("root");
		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			inBounds(s.length(), 4, 200, "s[" + (i + 1) + "].length");
			inBounds(s.charAt(0), 'A', 'Z', "Wrong disk name: " + s);
			s = s.toLowerCase();
			myAssert(s.charAt(1) == ':', "No ':' after disk name!!! " + s);
			myAssert(s.charAt(2) == '\\', "No '\\' after disk name!!! " + s);
			for (int j = 3; j < s.length(); j++) {
				inBounds(s.charAt(j), 33, 126, "s[" + (i + 1) + "][" + (j + 1)
						+ "]");
			}
			StringTokenizer st = new StringTokenizer(s, "\n\t\\");
			INode t = root;
			while (st.hasMoreTokens()) {
				myAssert(!t.isFile, "File and Directory have same names!!! "
						+ t.name);
				s = st.nextToken();
				if (!t.content.containsKey(s)) {
					t.content.put(s, new INode(s));
				}
				t = t.content.get(s);
			}
			myAssert(t.content.isEmpty(),
					"File and Directory have same names!!! " + t.name);
			t.isFile = true;
		}
		out.println(scan(root));
	}

	boolean[] test = new boolean[100];
	boolean[] answer = new boolean[100];

	private int scan(INode d) {
		int ans = 0;
		if (d.isFile) {
			return 0;
		}
		for (INode t : d.content.values()) {
			ans += scan(t);
		}
		Arrays.fill(test, false);
		Arrays.fill(answer, false);
		d.isTests = true;
		d.isContest = !d.content.isEmpty();
		for (INode t : d.content.values()) {
			d.isContest &= t.isProblem;
			if (t.isFile && d.isTests) {
				if (t.name.length() < 2) {
					d.isTests = false;
					break;
				}
				String s = t.name.substring(0, 2);
				int x = -1;
				if (!('0' <= s.charAt(0) && s.charAt(0) <= '9')
						|| !('0' <= s.charAt(1) && s.charAt(1) <= '9')) {
					d.isTests = false;
				} else {
					x = Integer.parseInt(s);
					if (s.equals(t.name)) {
						test[x] = true;
					} else if ((s + ".a").equals(t.name)) {
						answer[x] = true;
					} else {
						d.isTests = false;
					}
				}
			}
		}
		if (d.isTests) {
			if (test[0] || answer[0]) {
				d.isTests = false;
			} else {
				int n = 1;
				if (!test[1] || !answer[1]) {
					d.isTests = false;
				} else {
					while (n < test.length && test[n] && answer[n]) {
						n++;
					}
					if (n == 1) {
						d.isTests = false;
					} else {
						while (n < test.length && !test[n] && !answer[n]) {
							n++;
						}
						if (n < test.length) {
							d.isTests = false;
						}
					}
				}
			}
		}
		boolean hasTests = false;
		boolean hasChecker = false;
		for (String s : d.content.keySet()) {
			hasTests |= d.content.get(s).isTests;
			hasChecker |= s.startsWith("check.");
		}
		d.isProblem = hasTests && hasChecker;
		if (d.isContest) {
			ans++;
		}
		return ans;
	}

}
