Subsquares in a matrix

Given an n×mn \times m matrix of numbers between 1 and 9, compute how many subsquares 3×33 \times 3 it has with all the numbers between 1 and 9.

Input

Input consists of several cases. Every case begins with nn and mm, followed by an n×mn \times m matrix of integer numbers between 1 and 9. Suppose that nn and mm are between 3 and 100.

Output

For every matrix, print the number of subsquares 3×33 \times 3 that have all the numbers between 1 and 9.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:57:54.516Z

© Jutge.org, 2006–2026.
https://jutge.org