eolymp
bolt
Try our new interface for solving problems
Problems

Grid and phrase

Grid and phrase

You are given an $n \cdot m$ grid which contains lower case English letters. How many times does the phrase "\textbf{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} \InputFile The first line contains the number $n$ of rows and the number of columns $m~(1 \le n, m \le 100)$ in the grid. Each of the next $n$ lines contains a string of length $m$ whith lower case English letters only. \OutputFile Print the number of times the word "\textbf{saba}" appears in the grid.
Time limit 1 second
Memory limit 128 MiB
Input example #1
5 5
safer
amjad
babol
aaron
songs
Output example #1
2