/*
TASK: area
LANG: C++
*/

#include <cstdio>

const int MAXP = 1 << 10;//too much
//#warning check EPS
const double EPS = 1e-15;//there cannot be lines intersecting in the same point

struct pnt {
	double x, y;
	pnt () {}
	pnt (double _x, double _y) : x (_x), y (_y) {}
	pnt operator - (const pnt &a) const {return pnt (x - a.x, y - a.y);}
	pnt operator + (const pnt &a) const {return pnt (x + a.x, y + a.y);}
	pnt operator * (double a) const {return pnt (x * a, y * a);}
};

double _S (const pnt &a, const pnt &b, const pnt &c) {
//	printf ("we are here! (_S)\n");
	return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

int S (const pnt &a, const pnt &b, const pnt &c) {
//	printf ( "we are here (S)");
	static double tmp;
	return (tmp = _S (a, b, c)) > EPS ? 1 : tmp < -EPS ? -1 : 0;
}

pnt intersect (const pnt &p1, const pnt &q1, const pnt &p2, const pnt &q2) {
//	printf ("we are here (intersect) %lf %lf  %lf %lf   %lf %lf  %lf %lf -- ", p1.x, p1.y, q1.x, q1.y, p2.x, p2.y, q2.x, q2.y);
	double s1 = _S (p1, q2, p2), s2 = _S (q1, p2, q2);
//	printf ("%lf %lf\n", ((q1 - p1) * (s1 / (s1 + s2)) + p1).x , ((q1 - p1) * (s1 / (s1 + s2)) + p1).y);
	return (q1 - p1) * (s1 / (s1 + s2)) + p1;
}

pnt vecs[2][MAXP];
int vp[2];
pnt p;
int L;

int main () {
//	freopen ("area.in", "r", stdin);
	pnt dl, ur;
	scanf ("%lf %lf %lf %lf", &dl.x, &dl.y, &ur.x, &ur.y);
	vecs[0][vp[0]++] = dl;
	vecs[0][vp[0]++] = pnt (ur.x, dl.y);
	vecs[0][vp[0]++] = ur;
	vecs[0][vp[0]++] = pnt (dl.x, ur.y);

	scanf ("%lf %lf", &p.x, &p.y);
	scanf ("%d", &L);
//	printf ("%lf %lf  %lf %lf  %lf %lf %d\n", dl.x, dl.y, ur.x, ur.y, p.x, p.y, L);
	int i, j;
	int c = 1, o = 0;
	pnt line1, line2;
	int pnts, ps, cs;//point side, previous side, current side
	for (i = 0; i < L; ++i) {
		scanf ("%lf %lf %lf %lf", &line1.x, &line1.y, &line2.x, &line2.y);
//		printf ("scanned this line %lf %lf %lf %lf\n", line1.x, line1.y, line2.x, line2.y);
//		for (j = 0; j < vp[o]; ++j) printf (" (%lf %lf)", vecs[o][j].x, vecs[o][j].y); puts ("");
//		printf ("%lf\n", _S (line1, line2, p));
		pnts = S (line1, line2, p);
		vecs[o][vp[o]] = vecs[o][0];
		vp[c] = 0;
		ps = S (line1, line2, vecs[o][0]) * pnts;
		for (j = 1; j <= vp[o]; ++j) {
			cs = S (line1, line2, vecs[o][j]) * pnts;
//			printf ("looking at %lf %lf -- %d\n", vecs[o][j].x, vecs[o][j].y, cs);
			if (cs * ps < 0) vecs[c][vp[c]++] = intersect (line1, line2, vecs[o][j-1], vecs[o][j]);
			if (cs >= 0) vecs[c][vp[c]++] = vecs[o][j];
			ps = cs;
		}
		o = c;
		c = !c;
	}
//	for (j = 0; j < vp[o]; ++j) printf (" (%lf %lf)", vecs[o][j].x, vecs[o][j].y); puts ("");

//	printf ("are we here?!\n");

	vecs[o][vp[o]] = vecs[o][0];
	double res = 0;
	for (i = 0; i < vp[o]; ++i) {
	    res += vecs[o][i].x * vecs[o][i+1].y;
	    res -= vecs[o][i].y * vecs[o][i+1].x;
	}

	printf ("%d\n", (int)(res / 2.));

	return 0;
}
