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.

Difficulty: competition

Starter code:

Solutions:
"""
Codeforces Round 253 Div 1 Problem A

Author  : chaotic_iak
Language: Python 3.3.4
"""

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0:
        return inputs
    if mode == 1:
        return inputs.split()
    if mode == 2:
        return [int(x) for x in inputs.split()]

def write(s="\n"):
    if isinstance(s, list): s = " ".join(map(str,s))
    s = str(s)
    print(s, end="")

################################################### SOLUTION
import itertools
covers = itertools.product([0,1], repeat=10)

n, = read()
s = read(1)
a = [0] * 25
colors = "RGBYW"
for i in s:
    a[colors.index(i[0]) * 5 + int(i[1])-1] |= 1

def check(cover):
    nonlocal a
    unknowns = [0] * 11
    for i in range(25):
        if not a[i]: continue
        id = -1
        if not cover[i%5]: id = 5+i//5
        if not cover[5+i//5]:
            if id == -1:
                id = i%5
            else:
                id = 10
        if id > -1:
            if unknowns[id]: return False
            unknowns[id] = 1
    return True

mn = 99
for i in covers:
    if check(i):
        mn = min(mn, sum(i))

print(mn)

input()
colour = {'R': 0, 'G': 1, 'B': 2, 'Y': 3, 'W': 4}
cards = {(colour[c], ord(v) - ord('1')) for c, v in input().split()}

def ok(cs, vs):
    return len({
            (c if (cs >> c) & 1 else -1, v if (vs >> v) & 1 else -1)
            for c, v in cards
        }) == len(cards)

print((min(bin(cs).count('1') + bin(vs).count('1')
    for cs in range(1<<5) for vs in range(1<<5)
    if ok(cs, vs)
)))


import itertools


input()
cards = tuple(set(str.split(input())))
n = len(cards)

if n == 1:

    print(0)
    return

symbols = "RGBYW12345"
for l in range(1, 10):

    for comb in itertools.combinations(symbols, l):

        positions = [cards] * n
        for symbol in comb:

            for i in range(n):

                if symbol in cards[i]:

                    positions[i] = tuple([c for c in positions[i] if symbol in c])

                else:

                    positions[i] = tuple([c for c in positions[i] if symbol not in c])

        if sum(map(len, positions)) == n:

            print(l)
            return


input()
colour = dict(list(zip('RGBYW', list(range(5)))))
cards = {(colour[c], ord(v) - ord('1')) for c, v in input().split()}

print((min(bin(cs).count('1') + bin(vs).count('1')
    for cs in range(1<<5) for vs in range(1<<5)
    if len({
        (c if (cs >> c) & 1 else -1, v if (vs >> v) & 1 else -1)
        for c, v in cards
    }) == len(cards)
)))


from itertools import *
power = lambda i: chain.from_iterable(combinations(i, r) for r in range(len(i) + 1))
input()
cards = set(input().split())
print((min(len(s) for s in power("RGBYW12345") if
    len(set(str(set(s) & set(t)) for t in cards)) == len(cards)
)))


def check(hint, Card):
    for i in Card :
        for j in Card :
            if i == j : continue
            elif i[0] == j[0] :
                if i[1] not in hint and j[1] not in hint :
                    return False
            elif i[1] == j[1] :
                if i[0] not in hint and j[0] not in hint :
                    return False
            else :
                if i[0] not in hint and i[1] not in hint and j[0] not in hint and j[1] not in hint :
                    return False
    return True
HH = "RGBYW12345"
n = int(input())
Card = list(input().split(' '))
ans = 20
for i in range(1024):
    hint = ""
    cnt = 0
    for j in range(10) :
        if (2**j)&i > 0 :
            hint += HH[j]
            cnt+=1
    if check(hint, Card) :
        ans = min(ans, cnt)
print(ans)        

n = int(input())
colour = dict(zip('RGBYW', range(5, 10)))
cards = list({2 ** colour[c] + 2 ** (ord(v) - ord('1')) for c, v in input().split()})
ans = 10
n = len(cards)
if n > 1:
    for bit in range(2 ** 10):
        ok = True
        for i in range(n - 1):
            for j in range(i + 1, n):
                if cards[i] & cards[j] == 0:
                    if (cards[i] | cards[j]) & bit == 0:
                        ok = False
                        break
                elif cards[i] != cards[j]:
                    if (cards[i] ^ cards[j]) & bit == 0:
                        ok = False
                        break
            if not ok:
                break
        if ok:
            ans = min(bin(bit).count('1'), ans)
    print(ans)
else:
    print(0)

def Checker(hint,card):
    for a in card:
        for b in card:
            if a == b:
                continue
            elif a[0] == b[0]:
                if a[1] not in hint and b[1] not in hint:
                    return False
            elif a[1] == b[1]:
                if a[0] not in hint and b[0] not in hint:
                    return False
            elif a[0] not in hint and a[1] not in hint and b[0] not in hint and b[1] not in hint:
                return False
    return True

user_input=int(input())
user_input = input()
Card=user_input.split(' ')
possible_chars="RGBYW12345"

final_answer=10

card_set=set(Card)
if len(card_set)==1:
    print ("0")

else:

    for i in range(1024):
        hint=""
        counter=0
        for j in range(9,-1,-1):
            if (i-(2**j))>0:
                hint+=possible_chars[j]
                i-=2**j
                counter+=1

        if Checker(hint,card_set):
            final_answer=min(final_answer,counter)

    print (final_answer)


from itertools import combinations
n = int(input())
colors = {'R':0,'G':1,'B':2,'Y':3,'W':4}
letters = {'1':0,'2':1,'3':2,'4':3,'5':4}
l = list(set(list(input().split())))
def checker(hint,cards):
    for i in cards:
        for j in cards:
            if i == j:
                continue
            if i[0] == j[0]:
                if i[1] not in hint and j[1] not in hint:
                    return False
            elif i[1] == j[1]:
                if i[0] not in hint and j[0] not in hint:
                    return False
            else:
                if i[0] not in hint and i[1] not in hint and j[0] not in hint and j[1] not in hint:
                    return False
    return True
result = []
for i in l:
    if i[0] not in result:
        result.append(i[0])
    if i[1] not in result:
        result.append(i[1])
all_hints = []
for i in range(1,len(result)+1):
    comb = combinations(result,i)
    all_hints += comb
min_hint = len(result)
if len(l) == 1:
    print(0)
else:
    for i in all_hints:
        if checker(i,l):
            min_hint = min(len(i),min_hint)
    print (min_hint)



input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))

input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))


from itertools import chain, combinations
from copy import deepcopy
def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
n = int(input())
locations = input().split()
matrixG = [[0]*5 for i in range(5)]
for i in locations:
    if i[0] == "R":
        matrixG[0][int(i[1])-1] += 1
    elif i[0] == "G":
        matrixG[1][int(i[1])-1] += 1
    elif i[0] == "B":
        matrixG[2][int(i[1])-1] += 1
    elif i[0] == "Y":
        matrixG[3][int(i[1])-1] += 1
    elif i[0] == "W":
        matrixG[4][int(i[1])-1] += 1

for i in list(powerset(list(range(10)))):
    matrix = deepcopy(matrixG)
    color = []
    value = []
    for j in i:
        if j <= 4:
            color.append(j)
        else:
            value.append(j)
    for v in value:
        for c in color:
            matrix[c][v-5] = 0
        ctr = 0
        for r in range(5):
            if matrix[r][v-5] == 0:
                ctr += 1
        if ctr == 4:
            for r in range(5):
                matrix[r][v-5] = 0
    for c in color:
        if matrix[c].count(0) == 4:
            matrix[c] = [0]*5
    ctr = 0
    for k in range(5):
        for j in range(5):
            if matrix[k][j] == 0:
                ctr += 1
    if ctr == 24:
        print(len(i))
        break


input()

p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}

print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))




# Made By Mostafa_Khaled


input()
p={ (1<< 'RGBYW'.index(c)) + (1<<int(k)+4) for c, k in input().split()}
mn=20
res=90
for i in range(1024):
    if len(p)==len(set(i&j for j in p)):
        mn=min(mn,bin(i).count('1'))
print(mn)