{
TASK:area
LANG:Pascal
}

const inf=1000000;

type lines=Record
       x1,x2,y1,y2:Longint;
     End;
     points=Record
       x,y:extended;
       fromline:Array [1..2] of Longint;
     End;

function min(x:extended; y:extended):extended;
Begin
 If x<=y then min:=x else min:=y;
End;

function max(x:extended; y:extended):extended;
Begin
 If x>=y then max:=x else max:=y;
End;

procedure getAB(x1,y1,x2,y2:extended; var a:extended; var b:extended);
Begin
  a:=(y1-y2)/(x1-x2);
  b:=y1-a*x1;
End;

procedure getXY(a1,b1,a2,b2:extended; var x:extended; var y:extended);
Begin
  x:=(b2-b1)/(a1-a2);
  y:=a1*x+b1;
End;

var qx1,qy1,qx2,qy2,tx,ty,n,p,i,j,l,u,target,fin:Longint;
    a:Array[1..60] of lines;
    ip:Array[1..2000] of points;
    usable:Array[1..2000] of Boolean;
    point,per:Array[1..2000] of points;
    la1,lb1,la2,lb2,ix,iy,x,y,s,d1,d2,d3,hp:extended;
    found:Boolean;
Begin
  ReadLn(qx1,qy1,qx2,qy2);
  ReadLn(tx,ty);
  ReadLn(n);
  {Initial "lines"}
  a[1].x1:=qx1;
  a[1].y1:=qy1;
  a[1].x2:=qx1;
  a[1].y2:=qy2;
  a[2].x1:=a[1].x2;
  a[2].y1:=a[1].y2;
  a[2].x2:=qx2;
  a[2].y2:=qy2;
  a[3].x1:=a[2].x2;
  a[3].y1:=a[2].y2;
  a[3].x2:=qx2;
  a[3].y2:=qy1;
  a[4].x1:=a[3].x2;
  a[4].y1:=a[3].y2;
  a[4].x2:=qx1;
  a[4].y2:=qy1;

  p:=4;

  ip[1].x:=qx1;
  ip[1].y:=qy1;
  ip[1].fromline[1]:=1;
  ip[1].fromline[2]:=4;
  ip[2].x:=qx1;
  ip[2].y:=qy2;
  ip[2].fromline[1]:=1;
  ip[2].fromline[2]:=2;
  ip[3].x:=qx2;
  ip[3].y:=qy2;
  ip[3].fromline[1]:=2;
  ip[3].fromline[2]:=3;
  ip[4].x:=qx2;
  ip[4].y:=qy1;
  ip[4].fromline[1]:=3;
  ip[4].fromline[2]:=4;

  l:=4;

  {Lets get to business...}
 For i:=1 to n do
 Begin
   p:=p+1;
   ReadLn(a[p].x1,a[p].y1,a[p].x2,a[p].y2);
  For j:=1 to p-1 do
  Begin
    {Exceptions}
   If (a[j].x1=a[j].x2)and(a[p].x1=a[p].x2) then continue;
   If (a[j].x1=a[j].x2) then
    Begin
      getAB(a[p].x1,a[p].y1,a[p].x2,a[p].y2,la2,lb2);
      l:=l+1;
      ip[l].x:=a[j].x1;
      ip[l].y:=la2*a[j].x1+lb2;
      ip[l].fromline[1]:=j;
      ip[l].fromline[2]:=p;
      continue;
    End;
   If (a[p].x1=a[p].x2) then
   Begin
     getAB(a[j].x1,a[j].y1,a[j].x2,a[j].y2,la1,lb1);
     l:=l+1;
     ip[l].x:=a[p].x1;
     ip[l].y:=la1*a[p].x1+lb1;
     ip[l].fromline[1]:=j;
     ip[l].fromline[2]:=p;
     continue;
   End;
    {Ordinaries}
    getAB(a[j].x1,a[j].y1,a[j].x2,a[j].y2,la1,lb1);
    getAB(a[p].x1,a[p].y1,a[p].x2,a[p].y2,la2,lb2);
   If la1=la2 then continue; {in case they are parallel...}
    getXY(la1,lb1,la2,lb2,ix,iy);
    l:=l+1;
    ip[l].x:=ix;
    ip[l].y:=iy;
    ip[l].fromline[1]:=j;
    ip[l].fromline[2]:=p;
  End;
 End;
  {Lets eliminate the outer points}
 For j:=1 to l do usable[j]:=true;

 For i:=1 to p do
  For j:=1 to l do
  If(ip[j].fromline[1]<>i)and(ip[j].fromline[2]<>i) then
   Begin
     x:=ip[j].x;
     y:=ip[j].y;
    {Exceptions}
   If (x=tx)and(a[i].x1=a[i].x2) then continue;
   If (x=tx) then
    Begin
      getAB(a[i].x1,a[i].y1,a[i].x2,a[i].y2,la2,lb2);
      ix:=x;
      iy:=la2*ix+lb2;
     If (min(x,tx)<ix)and(ix<max(x,tx))and(min(y,ty)<iy)and(iy<max(y,ty)) then
      usable[j]:=false;
      continue;
    End;
   If (a[i].x1=a[i].x2) then
   Begin
     getAB(x,y,tx,ty,la1,lb1);
     ix:=a[i].x1;
     iy:=la1*ix+lb1;
    If (min(x,tx)<ix)and(ix<max(x,tx))and(min(y,ty)<iy)and(iy<max(y,ty)) then
     usable[j]:=false;
     continue;
   End;
    {Ordinaries}
    getAB(x,y,tx,ty,la1,lb1);
    getAB(a[i].x1,a[i].y1,a[i].x2,a[i].y2,la2,lb2);
   If la1=la2 then continue; {in case they are parallel...}
    getXY(la1,lb1,la2,lb2,ix,iy);
   If (min(x,tx)<ix)and(ix<max(x,tx))and(min(y,ty)<iy)and(iy<max(y,ty)) then
      usable[j]:=false;
   End;
  {Prepare the triangles}
 For i:=1 to l do
  If usable[i] then
   Begin
     u:=u+1;
     point[u]:=ip[i];
   End;
 {Debug ON}
 {For i:=1 to u do
 Begin
   WriteLn(point[i].x:5:5,' ',point[i].y:5:5,' ',point[i].fromline[1],' ',point[i].fromline[2]);
 End;}
 {Debug OFF}
  {Arrange polygon's sides}
  for i:=1 to u do usable[i]:=true;
  target:=point[1].fromline[1];
  usable[1]:=false;
  fin:=1;
  per[fin]:=point[1];
 Repeat
   found:=false;
  For i:=1 to u do
   If (usable[i])and((point[i].fromline[1]=target)or
   (point[i].fromline[2]=target)) then
   Begin
     fin:=fin+1;
     per[fin]:=point[i];
     usable[i]:=false;
    If point[i].fromline[1]<>target then target:=point[i].fromline[1]
                                    else target:=point[i].fromline[2];
     found:=True;
     {Debug ON}
     {WriteLn(i,' ->');}
     {Debug OFF}
     break;
   End;
 Until not found;
  {And finally we sum all little triange areas}
 For i:=1 to fin-1 do
 Begin
   d1:=sqrt(sqr(tx-per[i].x)+sqr(ty-per[i].y));
   d2:=sqrt(sqr(per[i].x-per[i+1].x)+sqr(per[i].y-per[i+1].y));
   d3:=sqrt(sqr(per[i+1].x-tx)+sqr(per[i+1].y-ty));
   hp:=(d1+d2+d3)/2;
   s:=s+sqrt(hp*(hp-d1)*(hp-d2)*(hp-d3));
 End;
  d1:=sqrt(sqr(tx-per[fin].x)+sqr(ty-per[fin].y));
  d2:=sqrt(sqr(per[fin].x-per[1].x)+sqr(per[fin].y-per[1].y));
  d3:=sqrt(sqr(per[1].x-tx)+sqr(per[1].y-ty));
  hp:=(d1+d2+d3)/2;
  s:=s+sqrt(hp*(hp-d1)*(hp-d2)*(hp-d3));
  WriteLn(trunc(s));
End.
