// Arup Guha
// 3/4/2023
// Alternate Solution to COP 4516 Team Contest #1 Problem: Welcome Party!

using namespace std;

#include <bits/stdc++.h>

int min(int a, int b);
int bitcnt(int n);

int main() {

    int n;
    cin >> n;

    // Process cases.
    while (n != 0) {

        // Small enough to make static.
        int list[300][2];

        // Read names, store initials as bitmasks.
        for (int i=0; i<n; i++) {
            string first, last;
            cin >> first >> last;

            // Extract vertex info.
            list[i][0] = (1<<(first[0] - 'A'));
            list[i][1] = (1<<(last[0] - 'A'));
        }

        // Will get overwritten...
        int res = 18;

        // Try each subset of last name groups.
        for (int mask=0; mask<(1<<18); mask++) {

            // Store first name groups we need.
            int firstMask = 0;

            // Go through list of names.
            for (int i=0; i<n; i++) {

                // Person is covered.
                if (mask & list[i][1]) continue;

                // Or in this bit.
                firstMask |= list[i][0];
            }

            // Update the result if necessary.
            res = min(res, bitcnt(mask)+bitcnt(firstMask));
        }

        // Ta da!
        cout << res << endl;

        // Get next case.
        cin >> n;
    }

    return 0;
}

// Returns # of bits on in n.
int bitcnt(int n) {
    int res = 0;
    for (int i=0; i<26; i++)
        if (n & (1<<i))
            res++;
    return res;
}

int min(int a, int b) {
    return a < b ? a : b;
}
