/**
*    author:  kuins_air
*    created: 07.05.2021 22:26:12
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, r, n) for(int i = r; i < n; i++)

int H, W, A[101][101];

int main() {
    cin >> H >> W;
    rep(h, 0, H) rep(w, 0, W) cin >> A[h][w];
    int m = 101;
    rep(h, 0, H) rep(w, 0, W) {
        m = min(m, A[h][w]);
    }

    int ans = 0;
    rep(h, 0, H) rep(w, 0, W){
        ans += A[h][w] - m;
    }
    cout << ans << endl;

    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int h, w;
	cin >> h >> w;
	vector<vector<int>> grid(h, vector<int>(w, 0));
	vector<vector<int>> hor(h, vector<int>(w, 0));
	vector<vector<int>> ver(h, vector<int>(w, 0));
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		hor[a][b] = 1;
		ver[a][b] = 1;
	}
	for (int i = 0; i < m; ++i) {
		int c, d;
		cin >> c >> d;
		c--; d--;
		grid[c][d] = 1;
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (j > 0 && ver[i][j - 1] && !grid[i][j]) ver[i][j] = 1;
		}
		for (int j = w - 2; j >= 0; --j) {
			if (j + 1 < w && ver[i][j + 1] && !grid[i][j]) ver[i][j] = 1;
		}
	}
	for (int j = 0; j < w; ++j) {
		for (int i = 0; i < h; ++i) {
			if (i > 0 && hor[i - 1][j] && !grid[i][j]) hor[i][j] = 1;
		}
		for (int i = h - 2; i >= 0; --i) {
			if (i + 1 < h && hor[i + 1][j] && !grid[i][j]) hor[i][j] = 1;
		}
	}
	int count = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			count += (ver[i][j] || hor[i][j]);
		}
	}
	cout << count << endl;
}

