program punch(input,output);
type
rec=record
x,y:longint;
end;
var
f:boolean;
i,j,k:longint;
n:longint;
a:array [1..10001] of rec;
ans:longint;
begin
assign(input,'punch.in');
assign(output,'punch.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
readln(a[i].x,a[i].y);
ans:=1;
for i:= 2 to n do begin
f:=true;
if (a[i].x<=a[i-1].x)and(a[i].y>=a[i-1].y)and (f)
then begin
ans:=ans+0;
f:=false;
end;
if (a[i].x>a[i-1].x) and (a[i].y<=a[i-1].y)and (f)
then begin
ans:=ans+1;
f:=false;
end;
if (a[i].x>=a[i-1].x) and (a[i].y<a[i-1].y)and (f)
then
begin
ans:=ans+1;
f:=false;
end;
if (a[i].x>=a[i-1].x) and (a[i].y>a[i-1].y) and (a[i].x<a[i-1].y) and (f)
then begin
ans:=ans+1;
f:=false;
end;
if (a[i].x<a[i-1].x) and (a[i].y<=a[i-1].y) and (a[i].y>a[i-1].x) and (f)
then begin
ans:=ans+1;
f:=false;
end;
if (a[i].x>=a[i-1].y) and (f)
then begin
ans:=ans+1;
f:=false;
end;
if (a[i].y<=a[i-1].x) and (f)
then begin
ans:=ans+1;
f:=false;
end;
end;
writeln(ans);
close(input);
close(output);
end.