Grid and phrase#11608

Grid and phrase

1 წამი
128 მეგაბაიტი
მარტივი

You are given an n \cdot m grid which contains lowercase English letters. How many times does the phrase saba appear horizontally, vertically, and diagonally in the grid?

The following word locations in the matrix are possible:

\includegraphics{https://eolympusercontent.com/images/7rujhg8vfh6bh0pdp8lupt0b90.gif}

შემავალი მონაცემები

The first line contains the number of rows and the number of columns (1 \leq n, m \leq 100) in the grid. Each of the next lines contains a string of length with lowercase English letters only.

გამომავალი მონაცემები

Print the number of times the word saba appears in the grid.

მაგალითები

მაგალითი 1

Loading
Loading