JOCHEF - Farmer Sepp


Chief Farmer Josef aka Sepp needs to crop hay several times through the summer. Due to high petrol costs he can currently use his truck only once to drive to a spot where he will harvest the dried grass. Lazy by nature, John does not want to harvest those parts of the field which contain cows, since this would involve too much energy. Furthermore, John just crops a rectangular part of the field.

Input

Input contains multiple test cases. You are given three integers M, N, F (0 < M, N ≤ 4000), (0 ≤ F ≤ 1000000) which describe the size of the field (M rows, N columns, F unit area of such a field). Then follows the actual map which consists of M lines, each line containing N times the letters 'H' or 'C' standing for "Hay" or "Cow". Input terminates with M = N = 0.

Output

Print the size of the largest field, which "Sepp" would harvest.

Example

Input:
9 10 1
CHCHHHCCCC
CCHCHCHHHC
CCHCHHCCCC
CHHHHHCHHH
CHCHHHCCCH
CCCCHHHCHH
HHHCCHCCCC
HCHHHHCCCH
CHHCCCCHHC
0 0

Output:
8

hide comments
Carlos Eduardo Rodrigues Alves [USJT]: 2010-06-09 18:02:09

The first line of the input description is a little confusing. It says that the first number indicates the number of columns, not rows.

Last edit: 2010-04-16 21:42:40
Josef Ziegler: 2010-06-09 18:02:09

Time limit was updated such that solutions with suboptimal complexity but fast I/O won't be accepted.


Added by:Josef Ziegler
Date:2010-04-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Josef Ziegler