Given an C
,
the second is an A
, the third is an L
, and the last is an I
, and two adjacent squares in the pattern
share at least a corner.
This selection process is repeated as many times as possible, with the caveat that a given square can only be selected at most once.
Compute the maximum number of distinct sets of letters that can be selected.
Constraints
In tests worth
In tests worth an additional
Input Specification
The first line of the input contains a single integer,
The next CALI
.
Output Specification
Output, on a single line, the maximum number of sets that can be selected.
Sample Input
Copy
4
CALI
ILAC
CLLC
IAAI
Sample Output
Copy
4
Comments