Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.

Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards except for Borya himself. Borya knows which cards he has but he knows nothing about the order they lie in. Note that Borya can have multiple identical cards (and for each of the 25 types of cards he knows exactly how many cards of this type he has).

The aim of the other players is to achieve the state when Borya knows the color and number value of each of his cards. For that, other players can give him hints. The hints can be of two types: color hints and value hints. 

A color hint goes like that: a player names some color and points at all the cards of this color. 

Similarly goes the value hint. A player names some value and points at all the cards that contain the value.

Determine what minimum number of hints the other players should make for Borya to be certain about each card's color and value.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of Borya's cards. The next line contains the descriptions of n cards. The description of each card consists of exactly two characters. The first character shows the color (overall this position can contain five distinct letters — R, G, B, Y, W). The second character shows the card's value (a digit from 1 to 5). Borya doesn't know exact order of the cards they lie in.

Output

Print a single integer — the minimum number of hints that the other players should make.

Examples

Input

2
G3 G3


Output

0


Input

4
G4 R4 R3 B3


Output

2


Input

5
B1 Y1 W1 G1 R1


Output

4

Note

In the first sample Borya already knows for each card that it is a green three.

In the second sample we can show all fours and all red cards.

In the third sample you need to make hints about any four colors.

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

/**
 * 10
 *
 * Y4 B1 R3 G5 R5 W3 W5 W2 R1 Y1
 *
 *
 * @author pttrung
 */
public class A {

    public static int Mod;
    public static int[] dp;
    public static int min;

    public static void main(String[] args) throws FileNotFoundException, IOException {

        Scanner in = new Scanner();
        //  PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        HashSet<String> data = new HashSet();
        String color = "RGBYW";
        boolean[] check = new boolean[5];
        boolean[] mark = new boolean[5];

        int c = 0, d = 0;
        for (int i = 0; i < n; i++) {
            String val = in.next();
            data.add(val);
            int index = color.indexOf(val.charAt(0));
            if (!check[index]) {
                c++;
                check[index] = true;
            }
            index = val.charAt(1) - '1';
            if (!mark[index]) {
                d++;
                mark[index] = true;
            }
        }
        int[] per = new int[c + d];
        for (int i = 0; i < per.length; i++) {
            per[i] = i;
        }
        check = new boolean[5];
        mark = new boolean[5];
        HashMap<Integer, Character> map = new HashMap();
        int num = 0;
        for (int i = 0; i < n; i++) {
            for (String val : data) {
                int a = color.indexOf(val.charAt(0));
                int b = val.charAt(1) - '1';
                if (!check[a]) {
                    map.put(num++, val.charAt(0));
                    check[a] = true;
                }
                if (!mark[b]) {
                    map.put(num++, val.charAt(1));
                    mark[b] = true;
                }
            }
        }
        n = data.size();
        String[] tmp = new String[n];
        int i = 0;
        for (String val : data) {
            tmp[i++] = val;
        }
        dp = new int[1 << (c + d)];
        Arrays.fill(dp, -1);
        int result = cal(0, c + d, map, new boolean[n], new boolean[n], tmp);
        out.println(result);
        out.close();
    }

    public static int cal(int mask, int n, HashMap<Integer, Character> map, boolean[] l, boolean[] r, String[] data) {
        if (isOk(l, r, data)) {
            return 0;
        }
        if (dp[mask] != -1) {
            return dp[mask];
        }
        boolean[] a = Arrays.copyOf(l, l.length);
        boolean[] b = Arrays.copyOf(r, r.length);
        int result = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            if (((1 << i) & mask) == 0) {
                char v = map.get(i);
                for (int j = 0; j < data.length; j++) {
                    if (v == data[j].charAt(0)) {
                        l[j] = true;
                    } else if (v == data[j].charAt(1)) {
                        r[j] = true;
                    }
                }
                int val = 1 + cal(mask | (1 << i), n, map, l, r, data);
                result = Math.min(val, result);
                l = Arrays.copyOf(a, a.length);
                r = Arrays.copyOf(b, b.length);
            }
        }
        dp[mask] = result;
        return result;
    }

    public static boolean isOk(boolean[] left, boolean[] right, String[] data) {


        ArrayList<Integer> list = new ArrayList();
        int[] a = new int[5];
        int[] b = new int[5];
        String color = "RGBYW";
        for (int i = 0; i < left.length; i++) {
            if (!left[i] || !right[i]) {

                int index = color.indexOf(data[i].charAt(0));
                int other = data[i].charAt(1) - '1';
                a[index]++;
                b[other]++;
                list.add(i);

            }
        }
        if (list.size() <= 1) {
            return true;
        }
        int c = list.size();
        boolean next = true;
        boolean[] check = new boolean[data.length];
        while (next) {
            next = false;
            for (int i : list) {
                if (!check[i]) {
                    int index = color.indexOf(data[i].charAt(0));
                    int other = data[i].charAt(1) - '1';

                    if (a[index] <= 1 && left[i]) {
                        a[index]--;
                        b[other]--;
                        next = true;
                        check[i] = true;
                        c--;
                    } else if (b[other] <= 1 && right[i]) {
                        a[index]--;
                        b[other]--;
                        next = true;
                        check[i] = true;
                        c--;
                    }
                }
            }
        }

        return c <= 1;
    }

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static class Point implements Comparable<Point> {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;

        }

        @Override
        public int compareTo(Point o) {
            if (x != o.x) {
                return x - o.x;
            }
            return y - o.y;
        }
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static int pow(int a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        int val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val;
        } else {
            return val * val * a;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
//    static Point minus(Point a, Point b) {
//        return new Point(a.x - b.x, a.y - b.y);
//    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//
//    static double cross(Point a, Point b) {
//        return a.x * b.y - a.y * b.x;
//
//
//    }
//
//    static class Point {
//
//        int x, y;
//
//        Point(int x, int y) {
//            this.x = x;
//            this.y = y;
//        }
//
//        @Override
//        public String toString() {
//            return "Point: " + x + " " + y;
//        }
//    }
    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large-practice.in")));
        }

        public String next() {


            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}