import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
private static int hash(char x) {
int res;
switch (x) {
case 'G' : res = 1; break;
case 'B' : res = 2; break;
case 'Y' : res = 3; break;
case 'W' : res = 4; break;
default : res = 0; break;
}
return res;
}
private static int popcount(int x) {
int res = 0, xx = x;
while (xx > 0) {
if ((xx & 1) > 0) res ++;
xx /= 2;
}
return res;
}
public static void main
(String[] args
) { InputReader in = new InputReader(inputStream);
int[][] st = new int[6][6];
int[][] cnt = new int[6][6];
int m, h = 0, v = 0, n;
n = in.nextInt();
for (int[] row : st)
while (n > 0) {
s = in.next();
st
[ hash
( s.
charAt(0) ) ][ Character.
getNumericValue( s.
charAt(1) ) ] = 2; n--;
}
for(int i = 0; i < 5; ++i) {
int meme = 0;
for(int j = 0; j < 5; ++j)
if (st[i][j] > 0) meme = 1;
v += meme;
}
for(int j = 0; j < 5; ++j) {
int meme = 0;
for(int i = 0; i < 5; ++i)
if (st[i][j] > 0) meme = 1;
h += meme;
}
for(int msk = 0; msk < (1 << 10); msk++) {
for(int i = 0; i < 5; ++i)
for(int j = 0; j < 5; ++j)
cnt[i][j] = st[i][j];
if (v > 1) {
for(int i = 0; i < 5; ++i)
if ( ( (1<<i) & msk/32 ) > 0)
for(int j = 0; j < 5; ++j)
cnt[i][j]--;
}
if (h > 1) {
for(int j = 0; j < 5; ++j)
if ( ( (1<<j) & msk ) > 0)
for(int i = 0; i < 5; ++i)
cnt[i][j]--;
}
int banjir = 0;
for(int i = 0; i < 5; ++i)
for(int j = 0; j < 5; ++j)
if (cnt[i][j] > 1)
banjir++;
boolean stat = (banjir < 2);
for(int i = 0; i < 5; ++i) {
if (!stat) break;
banjir = 0;
for(int j = 0; j < 5; ++j)
if (cnt[i][j] == 1)
banjir++;
stat = (banjir < 2);
}
for(int j = 0; j < 5; ++j) {
if (!stat) break;
banjir = 0;
for(int i = 0; i < 5; ++i)
if (cnt[i][j] == 1)
banjir++;
stat = (banjir < 2);
}
if (stat)
ans
= Math.
min(ans, popcount
(msk
)); }
out.println(ans);
out.close();
}
}
/* Java Template */
class InputReader {
tokenizer = null;
}
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
}
}
return tokenizer.nextToken();
}
public int nextInt() {
}
public long nextLong() {
return Long.
parseLong(next
()); }
}