/*
TASK:area
LANG:C
*/
#include <stdio.h>
#define min(a, b) (a<b?a:b)
#define max(a, b) (a>b?a:b)
#define isSameSign(a, b) ((a<0&&b<0) || (a>0&&b>0))
#define isSameH(tx, ty, qx, qy, x1, y1, x2, y2) (isSameSign(\
        (x1*(y2-ty) + x2*(ty-y1) + tx*(y1-y2)), \
        (x1*(y2-qy) + x2*(qy-y1) + qx*(y1-y2)) ))
#define abs(a) (a<0?a*-1:a)
#define isDbl0(a) (abs(a)<0.00001)
typedef struct pt POINT;
struct pt {int x, y;};

typedef struct dpt DPT;
struct dpt {double x, y;};
int X[2], Y[2], TX, TY, N;
main()
{
    DPT cont[100], in[100], pt;
    double ret=0;
    int i, a, b, c, d, t, res, numc, numin=0;
    int ptx1, pty1, ptx2, pty2;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    in[numin].x= min(a, c);
    in[numin++].y= min(b, d);
    in[numin].x= max(a, c);
    in[numin++].y= min(b, d);
    in[numin].x= max(a, c);
    in[numin++].y= max(b, d);
    in[numin].x= min(a, c);
    in[numin++].y= max(b, d);

    scanf("%d %d", &TX, &TY);
    scanf("%d", &N);

    for(i=0; i<N; i++)
    {
        numc=0;
        scanf("%d %d %d %d", &ptx1, &pty1, &ptx2, &pty2);
        for(t=0; t<numin; t++)
        {
            if(isSameH(in[t].x, in[t].y, TX, TY, ptx1, pty1, ptx2, pty2))
                cont[numc++] = in[t];
            if(isInX(in[t].x, in[t].y, in[(t+1)%numin].x, in[(t+1)%numin].y, 
                ptx1, pty1, ptx2, pty2, &pt))
                cont[numc++] = pt;
        }
        for(res=0; res<numc; res++)
            in[res] = cont[res];
        numin=numc;
    }
    for(res=0; res<numin; res++)
        ret+=in[res].x*in[(res+1)%numc].y - in[(res+1)%numc].x*in[res].y;
    printf("%ld\n", (long unsigned)abs(ret/2));
    return 0;
}

int isInX(double X1, double Y1, double X2, double Y2, 
          int x1, int y1, int x2, int y2, DPT* pt)
{
    int A1, B1, C1, A2, B2, C2;
double testx, testy;
    A1 = Y1 - Y2;
    B1 = X2 - X1;
    C1 = X1*Y2 - X2*Y1;
    A2 = y1 - y2;
    B2 = x2 - x1;
    C2 = x1*y2 - x2*y1;
    if(A1==0)
    {
        pt->y = Y1;
        if(!A2)return 0;
        pt->x = -((B2*(pt->y) + C2)/A2);
    }
    else if(B1==0)
    {
        pt->x = X1;
        if(!A2)return 0;
        pt->y = -((A2*(pt->x) + C2)/B2);
    }
    else
    {
        if(!(A1*B2-B1*A2))return 0;
        pt->x = (C1*B2 - B1*C2)/(B1*A2-A1*B2);
        pt->y = (C1*A2 - A1*C2)/(A1*B2-B1*A2);
    }
    return ((min(X1, X2) < pt->x && pt->x < max(X1, X2)) || isDbl0(X1-pt->x)) &&
           ((min(Y1, Y2) < pt->y && pt->y < max(Y1, Y2)) || isDbl0(Y1-pt->y));
}
    
