Given a maze of size

, where upper left corner is
_%7B%7D)
and lower right corner is
_%7B%7D)
. For each cell
_%7B%7D)
, there is exactly one character
)
on it, denoting the moving restriction:
* If

, you can only go up from this cell, specifically go from
_%7B%7D)
to
* If

, you can only go left from this cell, specifically go from
_%7B%7D)
to
* If

, you can only go down from this cell, specifically go from
_%7B%7D)
to
* If

, you can only go right from this cell, specifically go from
_%7B%7D)
to
We say one is out if

or

or

or

holds, now you should determine the number of cells that one can be out if start walking on it.