t={}
s={0}
while 1 do
	local a=io.read(1)
	if not(a)then break end
	table.insert(t,tonumber(a))
	table.insert(s,s[#s]+t[#t])
end
N=#t

r=0
for i=1,N do
for j=1,i-3 do
	if((s[i+1]-s[j])%3==0)then
		local n=0
		for k=j,i do
			n=n*10+t[k]
		end
		if(n%673==0)then r=r+1 end
	end
end
end
print(r)