<Problem>
http://ntucoder.net/Problem/Details/3350
Uses Crt;
Var s,temp:string; i,j,k:longint; sum,res,count:int64; check:boolean; a:array[0..10000009] of int64;
Begin
readln(s);
res:=0;
for i:=1 to length(s) do sum:=sum+(ord(s[i])-48);
if sum mod 3=0 then inc(res);
count:=0;
for i:=1 to length(s)-1 do //So ki tu can phai xoa
for j:=1 to length(s)-i+1 do //vi tri bat dau xoa
begin
sum:=0; check:=false;
temp:=s;
delete(temp,j,i);
for k:=1 to length(temp) do sum:=sum*10+(ord(temp[k])-48);
for k:=1 to count do
if a[k]=sum then begin check:=true; break; end;
if check=false then
begin
inc(count);
a[count]:=sum;
end;
end;
for k:=1 to count do
if a[k] mod 3=0 then inc(res);
writeln(res);
readln;
End.