Var a:array[1..1000]of integer; i,n,k,c,q:integer; begin readln(n); for i:=1 to n do begin readln(a[i]); if (a[i] mod 10 = 4) then begin k:=a[i]; c:=0; while k>0 do begin c:=c + k mod 10; k:= k div 10; end; if c mod 3 = 0 then q:=q+1; end; end; writeln(q); end.