Program enot;
var
  c, a : integer;
begin
  c:=0;
  repeat
    read (a);
     if (a mod 3=0) and (a mod 10=4) then inc (c);
  until a= 0;
  writeln (c);
end.