## 3-Dimensional Connect 4

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types

Raymond is very good at Connect 4. He thinks that regular Connect 4 is boring, so he plays a 3D version instead. The 3D version consists of parallel Connect 4 boards. Two players use red and yellow chips to attempt to connect 4 of their same color horizontally or vertically, across any of the three dimensions. Diagonal lines will not be counted for simplicity. Raymond is too lazy to check the board after a game himself, so he will pay you in points to check for him. Raymond always plays red.

#### Input Specification

The input will consist of line-separated grids, each denoting the chips in one slice of the 3D gameboard, and containing 36 characters that consist of R (for a red chip) and Y (for a yellow chip).

#### Output Specification

Output the number of distinct occurrences where 4 red chips are in a horizontal or vertical line in any of the three dimensions. If there are no such occurrences, output lost (Raymond is very competitive).

Note: Do not prompt for input, as this will cause the judge to take the prompt as the solution.

#### Sample Input

RYRRRY
RRYYRY
YYRYYR
YRYYRR
YYRRYR
RRYYRY

RYRRRY
RRYYRY
YYRYYR
YRYYRR
YYRRYR
RRYYRY

RYRRRY
RRYYRY
YYRYYR
YRYYRR
YYRRYR
RRYYRY

YRYYYR
YYRRYR
RRYRRY
RYRRYY
RRYYRR
YYRRYY

YRYYYR
YYRRYR
RRYRRY
RYRRYY
RRYYRR
YYRRRY

YRYYYR
YYRRYR
RRYRRY
RYRRYY
RRYYRR
YYRRRY

#### Sample Output

3