A. Borya and Hanabi
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Sample test(s)
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.

最新文章

  1. SQL Server 2008 R2——统计各部门某年入职人数
  2. Winform开发:在ProgressBar显示百分比数字
  3. ajax跨域往php程序post数据时,php程序总是执行两次的解决方法
  4. MySQL------如何将SQLServer文件数据迁移到MySQL
  5. 移动安全时代,如何保护你的app
  6. ASCII Table - ASCII码对照表
  7. PPTP模式跟L2TP模式有什么不同
  8. CSS3实现半像素边框
  9. Thread’s start method and run method
  10. C语言之形参和实参
  11. springMVC源码分析--动态样式ThemeResolver(一)
  12. linux下redis单机版搭建
  13. primo驱动启动顺序
  14. Golang 笔记 4 defer、error、panic
  15. opencv读取摄像头实时流代码
  16. pycharm2017自建注册服务器
  17. 003_Java笔记3:Eclipse添加jar包
  18. Redis 常见面试题
  19. poj 3264(RMQ或者线段树)
  20. Android蓝牙连接自动测试工具

热门文章

  1. 清除SQL Server 2008记住的数据库地址、登录名和密码
  2. 利用system-config-kickstart实现半自动化安装
  3. fork 和 exec
  4. nginx 配置虚拟机 支持pathinfo
  5. Vutrl 自己搞SS的些问题
  6. MVC Remote属性验证
  7. 准备新的代码迁移到cnblogs
  8. 【课余作品】简约QQ申请器(永久免费更新)
  9. [HDU4417]Super Mario(主席树+离散化)
  10. 【HDOJ6342】Expression in Memories(模拟)