/*
TASK:area
LANG:C++
*/
#include <iostream>
#include <set>
#include <cmath>
#define f first
#define s second
#define seti set<pair<double,double> >::iterator
#define EQ 1e-8

using namespace std;

inline int sign(long double __i)
{
	return (__i>0)?1:-1;
}

struct point
{
	double x,y;
};
point res[4096];

struct polar
{
	double ang,dist;
};
polar pol[4096];


int cmp(const void *a,const void *b)
{
	polar p1=*(polar*)a;
	polar p2=*(polar*)b;
	if(fabs(p1.ang-p2.ang)<EQ)
	{
		double t=p1.dist-p2.dist;
		if(fabs(t)<EQ)
			return 0;
		return sign(t);
	}
	if(p1.ang<p2.ang)
		return -1;
	return 1;
}

int gcd(int a,int b)
{
	if(!a)
		return b;
	if(!b)
		return a;
	while(a!=b)
		if(a>b)
			a-=b;
		else
			b-=a;
	return a;
}

int l,r,d,u,tx,ty,n,i,det,top=0,pos,x1,y11,x2,y2,j,g,ptsTop=0;
int a[64],b[64],c[64];
double x,y,minx=20000,miny=20000,area=0;
pair<double,double> pts[4096];
bool out[4096];
seti bu;
int main()
{
	cin>>l>>d>>r>>u;
	pts[ptsTop++]=make_pair(l,d);
	pts[ptsTop++]=make_pair(l,u);
	pts[ptsTop++]=make_pair(r,d);
	pts[ptsTop++]=make_pair(r,u);
	a[0]=0;
	b[0]=r-l;
	c[0]=(-b[0])*d;
	g=gcd(gcd(abs(a[0]),abs(b[0])),abs(c[0]));
	a[0]/=g;
	b[0]/=g;
	c[0]/=g;
	a[1]=d-u;
	b[1]=0;
	c[1]=(-a[1])*r;
	g=gcd(gcd(abs(a[1]),abs(b[1])),abs(c[1]));
	a[1]/=g;
	b[1]/=g;
	c[1]/=g;
	a[2]=0;
	b[2]=l-r;
	c[2]=(-b[2])*u;
	g=gcd(gcd(abs(a[2]),abs(b[2])),abs(c[2]));
	a[2]/=g;
	b[2]/=g;
	c[2]/=g;
	a[3]=u-d;
	b[3]=0;
	c[3]=(-a[3])*l;
	g=gcd(gcd(abs(a[3]),abs(b[3])),abs(c[3]));
	a[3]/=g;
	b[3]/=g;
	c[3]/=g;
	cin>>tx>>ty;
	cin>>n;
	n+=4;
	for(i=4;i<n;i++)
	{
		cin>>x1>>y11>>x2>>y2;
		a[i]=y11-y2;
		b[i]=x2-x1;
		c[i]=x1*y2-x2*y11;
		g=gcd(gcd(abs(a[i]),abs(b[i])),abs(c[i]));
		a[i]/=g;
		b[i]/=g;
		c[i]/=g;
		for(j=0;j<i;j++)
		{
			det=a[i]*b[j]-a[j]*b[i];
			if(det)
			{
				x=(b[i]*c[j]-b[j]*c[i])/(double)det;
				y=(c[i]*a[j]-c[j]*a[i])/(double)det;
				if((x>=l)&&(x<=r))
					if((y>=d)&&(y<=u))
						pts[ptsTop++]=make_pair(x,y);
			}
		}
	}
//	cout<<"inserted the points...\n";
//	for(i=0;i<ptsTop;i++)
//		if(!out[i])
//			cout<<pts[i].f<<" "<<pts[i].s<<"\n";
	for(i=4;i<n;i++)
	{
//		cout<<i<<" "<<a[i]*tx+b[i]*ty+c[i]<<"\n";
		int tt=sign(a[i]*tx+b[i]*ty+c[i]);
		for(j=0;j<ptsTop;j++)
			if(out[j])
				continue;
			else
			{
				double sn=a[i]*pts[j].f+b[i]*pts[j].s+c[i];
//				cout<<j<<" "<<sn<<"\n";
				if(fabs(sn)>EQ)
					if(sign(sn)!=tt)
					{
						out[j]=1;
//						cout<<"...\n";
					}
			}
	}
//	cout<<"deleted...\n";
//	for(i=0;i<ptsTop;i++)
//		if(!out[i])
//			cout<<pts[i].f<<" "<<pts[i].s<<"\n";
	for(i=0;i<ptsTop;i++)
		if(!out[i])
		{
			res[top].x=pts[i].f;
			res[top].y=pts[i].s;
//			cout<<res[top].x<<" "<<res[top].y<<"\n";
			if(res[top].x<minx)
			{
				minx=res[top].x;
				pos=top;
			}
			if(fabs(res[top].x-minx)<EQ)
				if(res[top].y<miny)
				{
					minx=res[top].x;
					miny=res[top].y;
					pos=top;
				}
			top++;
		}
//	for(i=0;i<top;i++)
//		if(!out[i])
//			cout<<res[i].x<<" "<<res[i].y<<"\n";
	swap(res[0],res[pos]);
//	cout<<top<<"\n"<<flush;
//	for(i=0;i<top;i++)
//			cout<<res[i].x<<" "<<res[i].y<<"\n";
	for(i=1;i<top;i++)
	{
		x=res[i].x-res[0].x;
		y=res[i].y-res[0].y;
		pol[i].ang=atan2(y,x);
		pol[i].dist=hypot(x,y);
	}
	qsort(pol+1,top-1,sizeof(pol[0]),cmp);
	for(i=1;i<top;i++)
	{
		res[i].x=pol[i].dist*cos(pol[i].ang)+res[0].x;
		res[i].y=pol[i].dist*sin(pol[i].ang)+res[0].y;
	}
//	for(i=0;i<top;i++)
//		cout<<res[i].x<<" "<<res[i].y<<"\n";
	res[top]=res[0];
	for(i=0;i<top;i++)
	{
		area+=res[i].x*res[i+1].y;
		area-=res[i+1].x*res[i].y;
	}
	cout<<abs(((int)area)>>1)<<"\n";
    return 0;
}
