#include using namespace std; template struct imos2D{ int h, w; std::vector> dat; imos2D(int H, int W) : h(H), w(W), dat(H + 1, std::vector(W + 1, 0)) {} void add(int ly, int lx, int ry, int rx, T v){ assert(0 <= ly && ly <= ry && ry <= h); assert(0 <= lx && lx <= rx && rx <= w); dat[ry][rx] += v; dat[ly][rx] -= v; dat[ry][lx] -= v; dat[ly][lx] += v; } void build(){ for(int i = 0; i <= h; i++) { for(int j = 1; j <= w; j++) { dat[i][j] += dat[i][j - 1]; } } for(int i = 0; i <= w; i++) { for(int j = 1; j <= h; j++) { dat[j][i] += dat[j - 1][i]; } } } const std::vector& operator[](int y) const { assert(0 <= y && y < h); return dat[y]; } std::vector& operator[](int y) { assert(0 <= y && y < h); return dat[y]; } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w, n; cin >> h >> w >> n; imos2D imos(h, w); for(int i = 0; i < n; i++){ int ly, lx, ry, rx; cin >> ly >> lx >> ry >> rx; ly--, lx--; imos.add(ly, lx, ry, rx, 1); } imos.build(); int ans = 0; for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ ans += imos[y][x] == 0; } } cout << ans << '\n'; }