// Arup Guha
// 10/26/2017
// Solution to 2013 MCPC Problem: Welcome Party that uses Meet in the Middle Technique.

import java.util.*;

public class welcome {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		
		// Process all cases.
		while (n != 0) {
			
			// Store initials with numbers 0-25.
			int[][] list = new int[n][2];
			for (int i=0; i<n; i++) 
				for (int j=0; j<2; j++) 
					list[i][j] = stdin.next().charAt(0)-'A';
			
			// Most number of groups if all first names had one.	
			int res = 26;
			
			// Go through all subsets of last names.
			for (int i=0; i<(1<<18); i++) {
				
				// Will keep track of who is in a group!
				boolean[] used = new boolean[n];
				
				// Mark all people in the groups by last name, where i is the subset of last name groups.
				for (int j=0; j<n; j++)
					if (((1<<(list[j][1])) & i) != 0)
						used[j] = true;
						
				// Now, for each person not in a group, mark their first name group as being needed.
				boolean[] first = new boolean[26];
				for (int j=0; j<n; j++)
					if (!used[j])
						first[list[j][0]] = true;
						
				// Last name groups counted here.
				int tmp = Integer.bitCount(i);
				
				// Add in first name groups.
				for (int j=0; j<26; j++)
					if (first[j])
						tmp++;
						
				// Update if necessary.
				res = Math.min(res, tmp);
			}
			
			// Ta da!
			System.out.println(res);
			
			// Go to the next case.
			n = stdin.nextInt();
		}
	}	
}