100 atcoder#ABC197B. [ABC197B] Visibility

[ABC197B] Visibility

Score : 200200 points

Problem Statement

We have a grid of HH horizontal rows and WW vertical columns, where some of the squares contain obstacles. Let (i,j)(i, j) denote the square at the ii-th row from the top and jj-th column from the left. You are given HH strings S1,S2,S3,,SHS_1, S_2, S_3, \dots, S_H. The jj-th character of SiS_i describes the square (i,j)(i, j); # means the square contains an obstacle, and . means it does not. We say a square is visible from another when it is on the same row or the same column, and there is no obstacle between them (including themselves). Print the number of squares visible from the square (X,Y)(X, Y) (including (X,Y)(X, Y) itself).

Constraints

  • 1H1001 \le H \le 100
  • 1W1001 \le W \le 100
  • 1XH1 \le X \le H
  • 1YW1 \le Y \le W
  • SiS_i is a string of length WW consisting of . and #.
  • The square (X,Y)(X, Y) does not contain an obstacle.

Input

Input is given from Standard Input in the following format:

HH WW XX YY

S1S_1

S2S_2

S3S_3

\hspace{3pt} \vdots

SHS_H

Output

Print the answer.

4 4 2 2
##..
...#
#.#.
.#.#
4

The squares visible from the square (2,2)(2, 2) are:

  • (2,1)(2, 1)
  • (2,2)(2, 2)
  • (2,3)(2, 3)
  • (3,2)(3, 2)
3 5 1 4
#....
#####
....#
4

Even if two squares are on the same row or the same column, they are not visible from each other when there are obstacles between them.

5 5 4 2
.#..#
#.###
##...
#..#.
#.###
3