// Arup Guha
// 7/16/2020
// Solution? to Kattis Problem Dance Recital (from 2015 MCPC)
// Written to illustrate brute force for SI@UCF lecture.

import java.util.*;

public class dance {

	public static int n;
	public static boolean[][] recitals;
	
	public static int[][] changes;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		
		// How I store the dances.
		recitals = new boolean[n][26];
		
		// Read in the dance routines.
		for (int i=0; i<n; i++) {
			char[] str = stdin.next().toCharArray();
			for (int j=0; j<str.length; j++)
				recitals[i][str[j]-'A'] = true;
		}
		
		// Pre-compute # of quick changes between any pair of routines.
		changes = new int[n][n];
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				
				// Go through all 26 dancers.
				for (int letter=0; letter<26; letter++)
					if (recitals[i][letter] && recitals[j][letter])
						changes[i][j]++;
			}
		}
		
		System.out.println(go(new int[n], 0, new boolean[n]));
	}
	
	public static int go(int[] perm, int k, boolean[] used) {
		
		// Done return the score of this dance schedule.
		if (k == n) return score(perm);
		
		// All scores lower than 1000.
		int res = 1000;
		
		// Try each routine next.
		for (int i=0; i<n; i++) {
			if (!used[i]) {
				perm[k] = i;
				used[i] = true;
				
				// Update if one of these possible routines is best.
				int tmp = go(perm, k+1, used);
				res = Math.min(res, tmp);
				used[i] = false;
			}
		}
		
		return res;
	}
	
	// Returns the sum of scores of changes by looking at my change array for each pair of consecutive dances.
	public static int score(int[] perm) {
		
		int res = 0;
		for (int i=0; i<n-1; i++) {
			res += changes[perm[i]][perm[i+1]];
		}
		return res;
		
	}

}