def calc(a,i,j,ans)
  n=0
  for k in i..j
    n+=a[k]*(10**(k-i))
  end
  if a[j]==0
    return ans
  end
  if n%11==0
    ans+=1
  end
  return ans
end

while n=gets.to_i
  if n==0
    break
  end
  count=0
  ans=0
  m=n
  while n>0
    n=n/10
    count+=1
  end
  a=Array.new(count)
  for i in 0..count-1
    a[i]=m%10
    m=m/10
  end
  for i in 0..count-2
    for j in i+1..count-1
      ans=calc(a,i,j,ans)
    end
  end
  print ans,"\n"
end
  