program tulips2;

const
    MAXN = 100000;

var
    K, N, bottomLeftX, bottomLeftY, bottomRightX, bottomRightY, i, topLeftX, topLeftY, topRightX, topRightY, angoloacuto, angolottuso, primo,secondo, terzo,quarto : LongInt;
    X, Y                                                                                                    : Array[0..MAXN-1] of LongInt;

function prodottoscalare(x1,y1,x2,y2,x3,y3,x4,y4:LongInt):LongInt;
var componenti:array[1..2,1..2] of LongInt;
 begin
    componenti[1,1]:=x2-x1;
    componenti[1,2]:=y2-y1;
    componenti[2,1]:=x4-x3;
    componenti[2,2]:=y4-y3;
    prodottoscalare:= componenti[1,1]* componenti[2,1]+componenti[1,2]* componenti[2,2];
 end;
 
begin
   
{
    uncomment the two following lines if you want to read/write from files
    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);
}

    ReadLn(topLeftX, topLeftY);

    ReadLn(topRightX, topRightY);

    ReadLn(bottomRightX, bottomRightY);

    ReadLn(bottomLeftX, bottomLeftY);

    ReadLn(N);

    for i:=0 to N-1 do
        ReadLn(X[i], Y[i]);

    K := 0;

    for i:=0 to N-1 do
             begin
               angoloacuto:=0; angolottuso:=0;
               primo:=prodottoscalare(X[i],Y[i],topLeftX, topLeftY,X[i],Y[i],bottomLeftX, bottomLeftY);
               if primo<0 then angoloacuto:=angoloacuto+1
                          else if primo>0 then angolottuso:=angolottuso+1;
               secondo:=prodottoscalare(X[i],Y[i],topLeftX, topLeftY,X[i],Y[i],topRightX, topRightY);
               if secondo<0 then angoloacuto:=angoloacuto+1
                          else if secondo>0 then angolottuso:=angolottuso+1;
               terzo:=prodottoscalare(X[i],Y[i],bottomLeftX, bottomLeftY,X[i],Y[i],bottomRightX, bottomRightY);
               if terzo<0 then angoloacuto:=angoloacuto+1
                          else if terzo>0 then angolottuso:=angolottuso+1;
               quarto:=prodottoscalare(X[i],Y[i],topRightX, topRightY,X[i],Y[i],bottomRightX, bottomRightY);
               if quarto<0 then angoloacuto:=angoloacuto+1
                          else if quarto>0 then angolottuso:=angolottuso+1;
               if  (angoloacuto=2) and (angolottuso=2) then k:=k+1;
            end;   
    WriteLn(K);
end.
