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.util.*;
import java.io.*;
import java.math.*;
@SuppressWarnings("unchecked")
public class Main {
    InputReader ir = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    int colarr[] = new int[5];
    int numarr[] = new int[5];
    boolean check[][] = new boolean[2500][2500];
     HashMap <Character, Integer> map = new HashMap();
    String arr[];
    int n;
    int min = 1000000;
    void solve(){
       n = ir.readInt();
       Set <String> set = new HashSet();
       for(int i = 0; i < n; i++) {
            String str = ir.readString();
            set.add(str);
       }
      
       map.put('R', 0);
       map.put('G', 1);
       map.put('B', 2);
       map.put('Y', 3);
       map.put('W', 4);
       n = set.size();
       int c = 0;
       arr = new String[n];
       for(String i: set) {
            arr[c++] = i;
            int idx = map.get(i.charAt(0));
            colarr[idx]++;
            idx = (int)(i.charAt(1) - '1');
            numarr[idx]++;
       }
       
       rec(0,0,0);
       out.println(min);
    }
    void rec(int colmask, int nummask, int count) {
        //out.println(colmask + " " +nummask);
        if(check[colmask][nummask] == true)
            return;
        check[colmask][nummask] = true;
        if(count >= min)
            return;
        //out.println(colmask + " " + nummask);
        boolean visit[] = new boolean[n];
        int tempcol[] = Arrays.copyOf(colarr, 5);
        int tempnum[] = Arrays.copyOf(numarr, 5);
        for(int i = 0; i < n; i++) {

            String str = arr[i];
            int col = map.get(str.charAt(0));
            int num = (int)(str.charAt(1) - '1');
            int mc = 1 << col;
            int mn = 1 << num;
            
            if(((((mc)&(colmask)) != 0) && (((mn)&(nummask))) != 0)) {
                
                visit[i] = true;
                tempcol[col]--;
                tempnum[num]--;
            }
        }

        for(int j = 0; j < n; j++)
        for(int i = 0; i < n; i++) {
            if(visit[i] == true)
                continue;
            String str = arr[i];
            int col = map.get(str.charAt(0));
            int num = (int)(str.charAt(1) - '1');
            int mc = 1 << col;
            int mn = 1 << num;
            if(((mc)&(colmask)) != 0) {
                if(tempcol[col] == 1) {
                    visit[i] = true;
                    tempcol[col]--;
                    tempnum[num]--;
                }
            } else if (((mn)&(nummask)) != 0 ) {
                if(tempnum[num] == 1) {
                    visit[i] = true;
                    tempcol[col]--;
                    tempnum[num]--;
                }
            }
        }
        int c = 0;

        for(int i = 0; i < n; i++) {
        
            if(visit[i] == false)
                c++;
        }
        if(c <= 1) {
            min = Math.min(count, count);
        }

        for(int i = 0; i < 5; i++) {
            if(((1 << i) & colmask) == 0) {
                rec((1 << i) | colmask, nummask, count + 1);
            }
            if(((1 << i) & nummask) == 0) {
                rec(colmask, (1 << i) | nummask, count + 1);
            }
         }

    }

    void run() {
        solve();
        out.close();
    }
    public static void main(String args[]) {
        new Main().run();
    }
}


class InputReader {
 
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;
 
    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 final 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 c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
 
    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }
        public double readDouble() {
        return Double.parseDouble(readString());
    }
 
    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
 
    public String next() {
        return readString();
    }
 
    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}
class Pair <Type1 extends Comparable<Type1>, Type2 extends Comparable<Type2>> implements Comparable <Pair<Type1, Type2>>{
    Type1 first;
    Type2 second;
    public Pair(Type1 F, Type2 S) {
        this.first = F;
        this.second = S;
    }
    @Override 
    public int compareTo(Pair <Type1, Type2> p) {
        if(first.compareTo(p.first) == 0)
            return second.compareTo(p.second);
        return first.compareTo(p.first);
    }
}
