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.math.*;
import java.io.*;
public class A {
	public static long time = 0;
	public static void main(String[] args) throws Exception {
		time = System.currentTimeMillis();
		
		IN = System.in;
		OUT = System.out;
		in = new BufferedReader(new InputStreamReader(IN));
		out = new PrintWriter(OUT, FLUSH);
		solveOne();
		out.flush();
	}
	
	public static void solveOne() throws Exception {
		String qq = "RGBYW";
		int n1 = nextInt();
		boolean[][] ex = new boolean[5][5];
		for (int i = 0 ;  i < n1; i++){
			char[] l1 = nextString().toCharArray();
			int a = qq.indexOf(l1[0]);
			int b = l1[1] - '1';
			ex[a][b] = true;
		}
		int cnt = 0;
		for (boolean[] e: ex){
			for (boolean f: e) if (f)cnt++;
		}
		if (cnt == 1){
			printLine(0);
		}
		else {
			int min = 123;
			int[][] paint = new int[5][5];
			HashSet<Integer> patternSet = new HashSet<>();
			for (int i = 0; i < (1 << 5); i++){
				for (int j = 0 ; j < (1 << 5); j++){
					int cur = 0;
					patternSet.clear();
//					px(String.format("%8s %8s", Integer.toBinaryString(i), Integer.toBinaryString(j)));
					for (int[] e: paint){
						Arrays.fill(e, 0);
					}
					for (int q1 = 0; q1 < 5; q1++){
						if (((1 << q1) & i) == 0) continue;
						for (int k = 0; k < 5; k++){
							paint[q1][k] |= 1 << q1;
						}
					}
					for (int q2 =0; q2 < 5; q2++){
						if (((1 << q2) & j) == 0) continue;
						for (int k = 0; k < 5; k++){
//							px("hit");
							paint[k][q2] |= 1 << (q2 + 7);
						}
					}
					
					for (int q1 = 0; q1 < 5; q1++){
						for (int q2 = 0; q2 < 5; q2++){
							if (ex[q1][q2]){
								patternSet.add(paint[q1][q2]);
							}
						}
					}
//					px(patternSet);
					if (cnt == patternSet.size() ){
						min = Math.min(min, Integer.bitCount(i) + Integer.bitCount(j));
					}
				}
			}
			printLine(min);
		}
	}
	
	public static void solveTwo() throws Exception {
		
	}
	
	public static void solveThree() throws Exception {
		
	}
	
	public static BufferedReader in;
	public static StringTokenizer st;
	public static InputStream IN;
	public static OutputStream OUT;
	public static String nextString() throws Exception {
		for (;st == null || !st.hasMoreTokens();){
			String k1 = in.readLine();
			if (k1 == null) return null;
			st = new StringTokenizer(k1);
		}
		return st.nextToken();
	}
	public static int nextInt () throws Exception {
		return Integer.parseInt(nextString());
	}
	public static long nextLong() throws Exception{
		return Long.parseLong(nextString());
	}
	public static double nextDouble() throws Exception{
		return Double.parseDouble(nextString());
	}
	private static int[] nextIntArray(int n1) throws Exception {
		int[] l1 = new int[n1];
		for (int i = 0 ;i < n1; i++){
			l1[i] = nextInt();
		}
		return l1;
	}
	private static long[] nextLongArray(int n1) throws Exception {
		long[] l1 = new long[n1];
		for (int i = 0 ;i < n1; i++){
			l1[i] = nextLong();
		}
		return l1;
	}
	private static int[][] nextIntGrid(int x, int y) throws Exception {
		int[][] l1 = new int[x][y];
		for (int i =0; i < x; i++){
			for (int j = 0; j < y; j++){
				l1[i][j] = nextInt();
			}
		}
		return l1;
	}
	public static void px(Object ... l1){
		System.out.println(Arrays.deepToString(l1));
	}
	public static boolean FLUSH = false;
	public static PrintWriter out;
	public static void print(Object ... l1){
		for (int i = 0; i < l1.length; i++){
			if (i != 0) out.print(' ');
			out.print(l1[i].toString());
		}
	}
	public static void printLine(Object ... l1){
		for (int i = 0; i < l1.length; i++){
			if (i != 0) out.print(' ');
			out.print(l1[i].toString());
		}
		out.println();
	}
	
	public static void printLine(Collection l1){
		boolean first = true;
		for (Object e: l1){
			if (first) first = false;
			else out.print(' ');
			out.print(e.toString());
		}
		out.println();
	}
	
	private static BigInteger bi(long n1){
		return BigInteger.valueOf(n1);
	}
	
	private static double usedTime(){
		return (System.currentTimeMillis()-time)*0.001;
	}
	private static Random usingRandomGenerator = new Random(System.currentTimeMillis());
	private static void sort(double[] l1){
		for (int i = 0 ;  i< l1.length; i++){
			int q = i + usingRandomGenerator.nextInt(l1.length - i);
			double t = l1[i];
			l1[i] = l1[q];
			l1[q] = t;
		}
		Arrays.sort(l1);
	}
	private static void sort(int[] l1){
		for (int i = 0 ;  i< l1.length; i++){
			int q = i + usingRandomGenerator.nextInt(l1.length - i);
			int t = l1[i];
			l1[i] = l1[q];
			l1[q] = t;
		}
		Arrays.sort(l1);
	}
	private static void sort(long[] l1){
		for (int i = 0 ;  i< l1.length; i++){
			int q = i + usingRandomGenerator.nextInt(l1.length - i);
			long t = l1[i];
			l1[i] = l1[q];
			l1[q] = t;
		}
		Arrays.sort(l1);
	}
	
	
	
}