Program n1;
function isch(var x: longint ): boolean;
var s: longint;
begin
s:=0;
isch:=false;
while ( x<>0 ) do
begin
s := s + (x mod 10);
x:= x div 10;
end;
if s mod 7=0 then isch:=true;
end;
var i,k,c: longint;
begin
k:=0;
for i:=100 to 999 do
begin
c:=i;
if (c mod 7=0) and isch(c) then k:=k+1;
end;
writeln(k);
end.