// Arup Guha
// 2/24/2022
// Solution to 2013 MCPC Problem: Welcome Party
// Written in class to illustrate hybrid brute force-greedy approach.

import java.util.*;

public class welcome_inclass {

	public static int n;
	public static char[] firstNames;
	public static char[] lastNames;
	
	public static void main(String[] args) {
	
		// Get first set size.
		Scanner stdin = new Scanner(System.in);		
		n = stdin.nextInt();
		
		// Process all cases.
		while (n != 0) {
		
			// Read in the names.
			firstNames = new char[n];
			lastNames = new char[n];
			for (int i=0; i<n; i++) {
				firstNames[i] = stdin.next().charAt(0);
				lastNames[i] = stdin.next().charAt(0);
			}
			
			// All groups, though 18 would have sufficed (all last names).
			int res = 44;
			
			// mask is my subset of which last names clubs I have.
			for (int mask=0; mask<(1<<18); mask++) 
				res = Math.min(res, getCost(mask));
		
			// Ta da!
			System.out.println(res);
		
			// Get next case.
			n = stdin.nextInt();
		}
	}
	
	// Returns the cost of using the subset indicated by mask for last names.
	public static int getCost(int mask) {
	
		// Groups we have based on last name.
		int res = Integer.bitCount(mask);
		
		// Store the first name letters we need here.
		boolean[] need = new boolean[26];
		
		// Go through the list.
		for (int i=0; i<n; i++) {
			
			// This person has a last name group, skip them.
			if (((1<<(lastNames[i]-'A')) & mask) != 0) continue;
			
			// If we get here, we must put this person in a first name group.
			need[firstNames[i]-'A'] = true;
		}
		
		// Add in all the first name groups we had to create and return.
		for (int i=0; i<26; i++)
			if (need[i])
				res++;
		return res;
	}
}