/ROBOT - Robot (OLPCĐ 2011)

<Problem>

http://ntucoder.net/Problem/Details/63
              Uses Crt;
        Var n,i,d:longint; a,b:array[1..1000000] of longint;
        Begin
            readln(n);
            for i:=1 to n do read(a[i],b[i]);
            for i:=2 to n-1 do
            begin
                //Moi mui ten duoc bieu dien bang toa do (i,i-1); 
                //Neu mui ten(i-1,i) di sang phai theo huong mui ten(i,i+1) thi inc(d)
                if (a[i-1]+1=a[i]) and (b[i]-1=b[i+1]) then inc(d) else
                if (b[i-1]+1=b[i]) and (a[i]+1=a[i+1]) then inc(d) else
                if (a[i-1]-1=a[i]) and (b[i]+1=b[i+1]) then inc(d) else
                if (b[i-1]-1=b[i]) and (a[i]-1=a[i+1]) then inc(d);
            end;
            writeln(d);
        End.