var
prev, num, count: integer;
begin
count := 0;
readln(prev);
while prev <= 1000 do
begin
readln(num);
if num > 1000 then
break;
if (prev mod 3 = 0) and (num mod 3 <> 0) then
inc(count);
prev := num;
end;
writeln(count);
end.