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

#include <cstdio>
#include <assert.h>
#include <cmath>
#include <vector>
using namespace std;

const double eps = 1e-9;

struct point {
       double x, y;
       point () {}
       point (double _x, double _y) : x(_x), y(_y) {}
};
struct segm {
       point a, b;
       segm () {}
       segm (point _a, point _b) : a(_a), b(_b) {}      
};

int n;
point Q1, Q2;
point T;
segm L;

vector<point> A;
double ans;

bool eq (double a, double b) { return fabs(a-b)<eps; }

bool between (double &a, double &b, double &c)
{
     return (a<b+eps) && (b<c+eps);
}

bool intersect (segm R, point &p)
{
     double A1 = L.a.y - L.b.y;
     double B1 = L.b.x - L.a.x;
     double C1 = L.a.x*L.b.y - L.b.x*L.a.y;
     
     double A2 = R.a.y - R.b.y;
     double B2 = R.b.x - R.a.x;
     double C2 = R.a.x*R.b.y - R.b.x*R.a.y;
     
     double den = A2*B1 - A1*B2;
     
     if ( eq(den,0.0) ) return 0;
     
     p.x = (C1*B2-C2*B1) / den;
     p.y = (A1*C2-A2*C1) / den;
     
     if (!between(R.a.x,p.x,R.b.x) && !between(R.b.x,p.x,R.a.x)) return 0;
     if (!between(R.a.y,p.y,R.b.y) && !between(R.b.y,p.y,R.a.y)) return 0;     
     
     return 1;
}

double orient (point &a, point &b, point &c)
{
       return (b.x-a.x)*(c.y-b.y) - (c.x-b.x)*(b.y-a.y);
}

void solve ()
{
     int curr, next;
     int from, to;
     point p;
     vector< point > S;
     vector< int > begin;
     vector< point > B;
     //vector< int > V(A.size()+3,0);
          
     for (curr=0; curr<A.size(); curr++) {
         next = (curr+1)%A.size();
         if ( intersect(segm(A[curr],A[next]),p) ) {
              S.push_back (p);
              begin.push_back (next);
         }
     }
    
     if (S.size() == 0) return;
     assert (S.size() == 2);
     
    // printf ("S[0] --> %.2lf %.2lf\n", S[0].x, S[0].y);
    // printf ("S[1] --> %.2lf %.2lf\n", S[1].x, S[1].y);

     from = begin[1];
     to   = begin[0];
     if ( orient(S[0],S[1],T) < 0 ) {
    //      printf ("direction: -\n");
          swap(S[0],S[1]);
          swap(from,to);
     }
     
    // printf ("from %d to %d\n", from, to); 
     
     B.push_back (S[0]);
     B.push_back (S[1]);
     
     for (curr=from%A.size(); curr!=to; curr=(curr+1)%A.size())
         B.push_back(A[curr]);
    
     A=B;
     
    // for (curr=0; curr<A.size(); curr++) printf ("A[%d] --> %.2lf %.2lf\n", curr, A[curr].x, A[curr].y);
}

double surface ()
{
      int curr, next;
      double S = 0.0;
      
      for (curr=0; curr<A.size(); curr++) {
          next = (curr+1)%A.size();
          S += (A[next].x-A[curr].x)*(A[next].y+A[curr].y)/2.0;
      }
      
      return fabs(S);
}

int main ()
{
    //freopen ("areabig.out", "r", stdin);
    
     int i;
     
     scanf ("%lf%lf%lf%lf", &Q1.x, &Q1.y, &Q2.x, &Q2.y);
     scanf ("%lf%lf", &T.x, &T.y);
     
     A.push_back ( point(Q1.x,Q1.y) );
     A.push_back ( point(Q2.x,Q1.y) );
     A.push_back ( point(Q2.x,Q2.y) );
     A.push_back ( point(Q1.x,Q2.y) );
     
     scanf ("%d", &n);
     
     for (i=0; i<n; i++) {
         scanf ("%lf%lf%lf%lf", &L.a.x, &L.a.y, &L.b.x, &L.b.y);
         solve ();
     }
     
     ans = surface();
     
     printf ("%.0lf\n", fabs(ans-0.5+eps));
    
    return 0;
}
