ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

## 1127. Colored Bricks

Time limit: 0.4 second
Memory limit: 64 MB
There are lots of cubic bricks in the kindergarten. Children like to build toy brick towers and then to drop them. It is clear that the higher tower has been built the more interesting it is to drop it. The tower is built by placing bricks one onto another and aligning their sides. The tower is based on one brick. Thus the height of a tower is the number of the bricks it is built of. Each side of a brick is painted in one color. So the kids build colored towers. In order to train the children's sense of beauty nannies teach them to build the towers in such a way that each side of the tower would be one-color. Thus the kids would like to build a tower with one-color sides as high as possible.
Every nanny can easily solve this problem. Try your best to do it as well.

### Input

The first line contains a number N (1 < N ≤ 103) — the number of bricks. The next N lines contain descriptions of bricks. Each brick is described with a string of 6 capital latin letters denoting the color of the corresponding side (A — Azure, B — Blue, C — Cyan, G — Green, O — Orange, R — Red, S — Scarlet, V — Violet, W — White, Y — Yellow). The colors of the sides are given in the following order: front, right, left, rear, top, bottom. A brick never has two sides of the same color.

### Output

Output the only number — the maximal height of a toy tower that can be built of the given brick set.

### Sample

inputoutput
```4
GYVABW
AOCGYV
CABVGO
OVYWGA
```
```3
```
Problem Author: Ekaterina Vasilyeva
Problem Source: VI Ural State University Collegiate Programming Contest (21.10.2001)
Tags: none