import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Dmitry Abdrashitov
 */
public class leftrec_da implements Runnable {
	
	private PrintWriter out;
	private BufferedReader in;
	private StringTokenizer st;
	
	private void solve() throws Exception {
		int n = nextInt();
		if (n < 1 || n > 1000) {
			throw new Exception("Wrong input data");
		}
		int answer = 0;
		for (int i = 0; i < n; i++) {
			nextLine();
			String str = nextToken();
			char left = str.charAt(0);
			if (left < 'A' || left > 'Z') {
				throw new Exception("Wrong input data");
			}
			if (!str.substring(1, 3).equals("->")) {
				throw new Exception("Wrong input data");
			}
			String right = str.substring(3);
			if (right.length() > 30) {
				throw new Exception("Wrong input data");
			}
			for (int j = 0; j < right.length(); j++) {
				char c = right.charAt(j);
				if (!(c >= 'a' && c <= 'z') && !(c >= 'A' && c <= 'Z')) {
					throw new Exception("Wrong input data");
				}
			}
			if (right.charAt(0) == left) {
				answer++;
			}
		}
		out.println(answer);
	}
	
	public void run() {
		try {
			solve();
		} catch (Exception e) {
			apstenu(e);
		} finally {
			out.close();
		}
	}
	
	private void apstenu(Exception e) {
		e.printStackTrace();
		System.exit(239);
	}
	
	private void nextLine() throws Exception {
		st = new StringTokenizer(in.readLine());
	}
	
	private int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	private String nextToken() throws Exception {
		return st.nextToken();
	}
	
	private leftrec_da(String name) {
		try {
			out = new PrintWriter(new FileWriter(name + ".out"));
			in = new BufferedReader(new FileReader(name + ".in"));
			st = new StringTokenizer(in.readLine());
		} catch (Exception e) {
			apstenu(e);
		}
	}

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