Codeforces Round 253 (Div. 2)
C
Borya and Hanabi
Codeforces
未评级
原题
← BD →
翻译中…

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.

翻译中…

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.

翻译中…

样例

Input #1
2
G3 G3
Output #1
0
InputCopy OutputCopy
Input #2
4
G4 R4 R3 B3
Output #2
2
InputCopy OutputCopy
Input #3
5
B1 Y1 W1 G1 R1
Output #3
4
InputCopy OutputCopy
题目信息
题号
443C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。