#D10238. String

    ID: 8509 Type: Default 1000ms 268MiB

String

String

problem

Given N N strings Si S_i .

Find the maximum number of "AOR" in the string obtained by connecting Si S_i in any order.

output

Output the maximum number of "AOR" contained in the character string obtained by connecting Si S_i in any order. Also, output a line feed at the end.

Example

Input

2 AORA OR

Output

2

inputFormat

outputFormat

output

Output the maximum number of "AOR" contained in the character string obtained by connecting Si S_i in any order. Also, output a line feed at the end.

Example

Input

2 AORA OR

Output

2

样例

2
AORA
OR
2