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.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;

/**
 * Ashesh Vidyut (Drift King) *
 */
public class A{
    public static void main(String[] args) {
        try {
            InputReader in = new InputReader(System.in);
            int n = in.readInt();
            Hashtable<Integer, Vector<Character>> num_col = new Hashtable<Integer, Vector<Character>>();
            Hashtable<Character, Vector<Integer>> col_num = new Hashtable<Character, Vector<Integer>>();
            String colr = "RGBYW";
            for (int i = 0; i < colr.length(); i++) {
                col_num.put(colr.charAt(i), new Vector<Integer>());
                num_col.put(i, new Vector<Character>());
            }
            String inp[] = (in.readLine()).split(" ");
            for (int i = 0; i < inp.length; i++) {
                char c = inp[i].charAt(0);
                int num = Integer.parseInt(Character.toString(inp[i].charAt(1)));
                col_num.get(c).add(num - 1);
                num_col.get(num - 1).add(c);
            }
            boolean allequal = true;
            String f = inp[0];
            for (int i = 1; i < inp.length; i++) {
                if(!inp[i].equals(f)){
                    allequal = false;
                    break;
                }
            }
            if(allequal){
                System.out.println(0);
                return ;
            }
            int ans = Integer.MAX_VALUE;
            for (int mask = 1; mask < (1 << 10); mask++) {
                Hashtable<Character, Vector<Integer>> col_num_copy = new Hashtable<Character, Vector<Integer>>();
                for (int i = 0; i < 5; i++) {
                    char c = colr.charAt(i);
                    Vector<Integer> numvec = col_num.get(c);
                    Vector<Integer> newnvcopy = new Vector<Integer>();
                    for(int num : numvec){
                        newnvcopy.add(num);
                    }
                    col_num_copy.put(c, newnvcopy);
                }
                Hashtable<Integer, Vector<Character>> num_col_copy = new Hashtable<Integer, Vector<Character>>();
                for (int i = 0; i < 5; i++) {
                    int num = i;
                    Vector<Character> charvec = num_col.get(num);
                    Vector<Character> newcharvec = new Vector<Character>();
                    for(char c : charvec){
                        newcharvec.add(c);
                    }
                    num_col_copy.put(num, newcharvec);
                }
                int count = 0;
                Vector<Card> carvec = new Vector<Card>();
                boolean canguess = false;
                String binarymask = Integer.toBinaryString(mask);
                for (int i = 0; i < 10; i++) {
                    if((mask & (1 << i)) != 0){
                        count++;
                        if(i <= 4){
                            char c = colr.charAt(i);
                            Vector<Integer> numbers = col_num_copy.get(c);
                            for(int numwithcol : numbers){
                                boolean assigned = false;
                                for (int ind = 0; ind < carvec.size(); ind++) {
                                    Card card = carvec.get(ind);
                                    if(card.col == 'x' && card.num == numwithcol){
                                        card.col = c;
                                        assigned = true;
                                        break;
                                    }
                                }
                                if(!assigned){
                                    carvec.add(new Card(c));
                                }
                            }
                        }
                        else{
                            int num = i - 5;
                            Vector<Character> cols = num_col_copy.get(num);
                            for(char colwithnum : cols){
                                boolean assigned = false;
                                for (int ind = 0; ind < carvec.size(); ind++) {
                                    Card card = carvec.get(ind);
                                    if(card.num == -7 && card.col == colwithnum){
                                        card.num = num;
                                        assigned = true;
                                        break;
                                    }
                                }
                                if(!assigned){
                                    carvec.add(new Card(num));
                                }
                            }
                        }
                    }
                }
                int countguessed = 0;
                boolean complete[] = new boolean[carvec.size()];
                for (int ind = 0; ind < carvec.size(); ind++) {
                    Card card = carvec.get(ind);
                    if(card.col != 'x' && card.num != -7){
                        num_col_copy.get(card.num).remove(new Character(card.col));
                        col_num_copy.get(card.col).remove(new Integer(card.num));
                        countguessed++;
                        complete[ind] = true;
                    }
                }
                if(countguessed == n){
                    canguess = true;
                }
                else{
                    for (int i = 0; i < complete.length; i++) {
                        if(complete[i])
                            continue;
                        Card c = carvec.get(i);
                        if(c.num == -7){
                            char col = c.col;
                            Vector<Integer> numbers = col_num_copy.get(col);
                            if(numbers.isEmpty()){
                                complete[i] = false;
                                break;
                            }
                            boolean allEqualNum = true;
                            int fn = numbers.get(0);
                            for (int j = 1; j < numbers.size(); j++) {
                                if(fn != numbers.get(j)){
                                    allEqualNum = false;
                                    break;
                                }
                            }
                            if(numbers.size() == 1 || allEqualNum){
                                int num = numbers.get(0);
                                numbers.remove(0);
                                col_num_copy.put(col, numbers);
                                c.num = num;
                                Vector<Character> chvec = num_col_copy.get(num);
                                chvec.remove(new Character(c.col));
                                num_col_copy.put(c.num, chvec);
                                complete[i] = true;
                            }
                            else{
                                complete[i] = false;
                                break;
                            }
                        }
                        else if(c.col == 'x'){
                            int num = c.num;
                            Vector<Character> cols = num_col_copy.get(num);
                            if(cols.isEmpty()){
                                complete[i] = false;
                                break;
                            }
                            boolean allEqualChar = true;
                            char fc = cols.get(0);
                            for (int j = 0; j < cols.size(); j++) {
                                if(fc != cols.get(j)){
                                    allEqualChar = false;
                                    break;
                                }
                            }
                            if(cols.size() == 1 || allEqualChar){
                                char col = cols.get(0);
                                cols.remove(0);
                                num_col_copy.put(num, cols);
                                c.col = col;
                                Vector<Integer> nvec = col_num_copy.get(c.col);
                                nvec.remove(new Integer(num));
                                col_num_copy.put(col, nvec);
                                complete[i] = true;
                            }
                            else{
                                complete[i] =false;
                                break;
                            }
                        }
                    }
                    boolean allmatched = false;
                    boolean allcomplete[] = new boolean[complete.length];
                    Arrays.fill(allcomplete, true);
                    if(Arrays.equals(complete, allcomplete)){
                        allmatched = true;
                    }
                    if(allmatched){
                        int matched = complete.length;
                        HashSet<Character> used = new HashSet<Character>();
                        for (int i = 0; i < 5; i++) {
                            Vector<Character> charvec = num_col_copy.get(i);
                            if(charvec.isEmpty()){
                                continue;
                            }
                            boolean allsame = true;
                            char fc = charvec.get(0);
                            for (int j = 0; j < charvec.size(); j++) {
                                if(fc != charvec.get(j)){
                                    allsame = false;
                                    break;
                                }
                            }
                            if(allsame){
                                if(used.isEmpty()){
                                    used.add(fc);
                                    matched += charvec.size();
                                }
                                else{
                                    break;
                                }
                            }
                            else{
                                break;
                            }
                        }
                        if(matched == n){
                            canguess = true;
                        }
                    }
                }
                if(canguess){
                    ans = Math.min(ans, count);
                }
            }
            System.out.println(ans);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
class Card{
    char col;
    int num;
    public Card(int n){
        this.num = n;
        this.col = 'x';
    }
    public Card(char col){
        this.col = col;
        this.num = -7;
    }
    public Card(int num, char c){
        this.num = num;
        this.col = c;
    }
    public Card(char c, int n){
        this.col = c;
        this.num = n;
    }
}class InputReader {
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int peek() {
        if (numChars == -1)
            return -1;
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                return -1;
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int length = readInt();
        if (length < 0)
            return null;
        byte[] bytes = new byte[length];
        for (int i = 0; i < length; i++)
            bytes[i] = (byte) read();
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return new String(bytes);
        }
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0() {
        StringBuffer buf = new StringBuffer();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public String readLine() {
        String s = readLine0();
        while (s.trim().length() == 0)
            s = readLine0();
        return s;
    }

    public String readLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines)
            return readLine();
        else
            return readLine0();
    }

    public BigInteger readBigInteger() {
        try {
            return new BigInteger(readString());
        } catch (NumberFormatException e) {
            throw new InputMismatchException();
        }
    }

    public char readCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted() {
        int value;
        while (isSpaceChar(value = peek()) && value != -1)
            read();
        return value == -1;
    }

    public String next() {
        return readString();
    }

    public boolean readBoolean() {
        return readInt() == 1;
    }
}

