시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB435696022.140%

문제

You have placed glues on each cells of an $N\times M$ grid to create a rectangular flea trap. Each glue has a weak direction; if a flea on the glue jumps towards its weak direction, the flea can jump out of the glue.

More precisely, each glue is represented by U, D, L, or R, meaning up, down, left, and right respectively.

Fleas can jump at most $K$ cells in one jump. If a flea jumps out of the rectangle, we say that the flea has escaped.

You became curious about how effective your trap is. If a flea that is placed on a cell of the trap can escape after consecutive jumps, we call the cell an escapable cell. Your task is to count the number of escapable cells.

입력

In the first line, the trap sizes $N$, $M$ and the jump limit $K$ are given, separated by spaces.

For the next $N$ lines, each line contains a string of length $M$, indicating the weak direction of each cell.

출력

Print the number of escapable cells.

제한

  • $N$, $M$, and $K$ are integers.
  • $1\le N\le 2\, 000$
  • $1\le M\le 2\, 000$
  • $1\le K\le 2\, 000$
  • Each string consists of U, D, L, or R.

예제 입력 1

5 5 2
DDDRD
DDDDD
RDLUL
UURUU
UUUUU

예제 출력 1

14

Fleas which start from (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 3), (4, 4), (4, 5), (5, 3), (5, 4), and (5, 5) can escape.

  • A flea at (1, 3) can escape by jumping along the following path: (1, 3) $\rightarrow$ (2, 3) $\rightarrow$ (4, 3) $\rightarrow$ (4, 4) $\rightarrow$ (3, 4) $\rightarrow$ (1, 4) $\rightarrow$ out of the trap
  • A flea at (1, 4) can escape by jumping two glues to the right.