We love to CODE

5

2 votes
Easy
Problem

We love to code. Thereby we also like the four characters, 'c', 'o', 'd' and 'e'.

A substring of the given string, S is called "Eunoia string" if the frequency of characters  'c', 'o', 'd' and 'e' in the substring is equal to each other.

Find the number of "Eunoia strings" in the given string, S .

Input Format: -

First line contains N – no of characters in string, S. Next line contains the string S.

Output Format: -

Output a single integer denoting the number of "Eunoia strings" in S.

Constraints:

1 <= N <= 105

All the characters of the string S are lowercase alphabets.

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The "Eunoia strings" are (0,3), (1,4), (2,5), (3,6), (4,7) and (0,7).

Editor Image

?