Equal Zero One And Two

easy
1. Given a string which consists of only 0, 1 or 2s, count the number of substring which have equal number of 0s, 1s and 2s.

Input Format

First line contains a string of 0's, 1's and 2's.

Output Format

Print an integer(count of all possible substrings that have same number of 0s, 1s and 2s.)

Constraints

1 <= string length <= 1000

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
102100211
Output
5
Previous
Find All Four Sum Numbers
Next
Find First Repeated Character

Related Questions