#include <vector>
#include <iostream>
#include <fstream>
#include <cstdio>

using namespace std;

const int MAXN = 201;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

int a[MAXN][MAXN];

int main()
{
	ifstream cin("assault.in");
	ofstream cout("assault.out");
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];
	int ans = 0;
	for (int i = 1; i < n; i++)
		for (int j = 1; j < m; j++)
		{
			int cnt = 0;
			for (int k = 0; k < 4; k++)
				cnt += (a[i][j] > a[i + dx[k]][j + dy[k]]);
			ans += cnt == 4;
		}
	cout << ans;
}