#include <bits/stdc++.h>
using namespace std;
const int NN = 5;
string color = "RGBYW", value = "12345", s;
int N;
int findRow(string temp) {
  for (int i = 0; i < NN; ++i)
    if (temp[0] == color[i]) return i;
}
int findCol(string temp) {
  for (int i = 0; i < NN; ++i)
    if (temp[1] == value[i]) return i;
}
int filled(int rbit, int i) { return ((rbit >> i) & 1); }
int conn(int gbit, int i, int j) { return ((gbit >> (i * NN + j)) & 1); }
bool all(int gbit) {
  for (int i = 0; i < NN; ++i)
    for (int j = 0; j < NN; ++j)
      if (conn(gbit, i, j)) return false;
  return true;
}
void identify(int rbit, int cbit, int &gbit) {
  for (int i = 0; i < NN; ++i)
    for (int j = 0; j < NN; ++j)
      if (filled(rbit, i) and filled(cbit, j) and conn(gbit, i, j))
        gbit -= (1 << (i * NN + j));
}
void update(int &rbit, int &cbit, int &gbit) {
  identify(rbit, cbit, gbit);
start : {}
  int temp = gbit;
  int r = 0, c = 0;
  for (int i = 0; i < NN; ++i) {
    bool flag = false;
    for (int j = 0; j < NN; ++j)
      if (conn(gbit, i, j)) flag = true;
    if (!filled(rbit, i) and flag) ++r;
  }
  if (r <= 1) rbit = (1 << NN) - 1;
  for (int i = 0; i < NN; ++i) {
    bool flag = false;
    for (int j = 0; j < NN; ++j)
      if (conn(gbit, j, i)) flag = true;
    if (!filled(cbit, i) and flag) ++c;
  }
  if (c <= 1) cbit = (1 << NN) - 1;
  for (int i = 0; i < NN; ++i) {
    if (!filled(rbit, i)) continue;
    int ct = 0;
    for (int j = 0; j < NN; ++j)
      if (conn(gbit, i, j)) ++ct;
    if (ct <= 1)
      for (int j = 0; j < NN; ++j)
        if (conn(gbit, i, j)) gbit -= (1 << (i * NN + j));
  }
  for (int i = 0; i < NN; ++i) {
    if (!filled(cbit, i)) continue;
    int ct = 0;
    for (int j = 0; j < NN; ++j)
      if (conn(gbit, j, i)) ++ct;
    if (ct <= 1)
      for (int j = 0; j < NN; ++j)
        if (conn(gbit, j, i)) gbit -= (1 << (j * NN + i));
  }
  identify(rbit, cbit, gbit);
  if (temp != gbit) goto start;
}
int moves(int rbit, int cbit, int gbit) {
  update(rbit, cbit, gbit);
  if (all(gbit)) return 0;
  int ans = 112345678;
  for (int i = 0; i < NN; ++i) {
    if ((rbit >> i) & 1) continue;
    ans = min(moves(rbit + (1 << i), cbit, gbit) + 1, ans);
  }
  for (int i = 0; i < NN; ++i) {
    if ((cbit >> i) & 1) continue;
    ans = min(moves(rbit, cbit + (1 << i), gbit) + 1, ans);
  }
  return ans;
}
void solve() {
  cin >> N;
  int gbit = 0;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    int x = findRow(s), y = findCol(s);
    if (!conn(gbit, x, y)) gbit += (1 << (x * NN + y));
  }
  int ans = moves(0, 0, gbit);
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
