Strings Hate Zeroes

0

0 votes
Medium-Hard
Problem

Consider a string s of length n consisting of characters 0 to 9. Let r(s) be the number of distinct characters this string has, and N(c) be the number of times character c appears in the string. We call the string s happy if N(0)<nr(s)

For example strings 010 and 012 are NOT happy, but strings 0112 and 123456789 are happy.

Given a string S, find the number of happy substrings(out of a total |S|(|S|+1)2 ) of S.

Input
The only line of the input contains the string S

Output
Print one line containing the number of happy substrings of S

Constraints

  • |S|105
Time Limit: 1
Memory Limit: 512
Source Limit:
Editor Image

?