Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Code Generator

By borisal · Limits 500ms, 512 MB

Disha has a string SS. In one second, Disha can choose a subsequence from SS that make the word “code” and remove it from the string. The process will be continued until she can't choose a subsequence that make the word.

In this problem, Good letter means [c,d,e,o]. And others letters are Bad.

Now, you have to find the maximum number of seconds Disha will work.

Input

The first line of the input contains a single integer nn- the length of the string ss.
Next line contains string ss. the string consists of only lowercase English letters.

Constraints

Subtask 1 (10 points)

1n50001 \le n \le 5000

Subtask 2 (30 points)

1n5000001 \le n \le 500000
Number of good letters 5000\leq 5000

Subtask 3 (60 points)

1n5000001 \le n \le 500000

Output

Output the maximum number of seconds Disha will work.

Sample

InputOutput
8
codceode
2

    Discussion

    Statistics


    53% Solution Ratio

    Tahmid690Earliest, Jun '20

    riyad000Fastest, 0.0s

    ITisMAHMUDLightest, 131 kB

    bokaifShortest, 132B

    Submit

    Login to submit

    Toph uses cookies. By continuing you agree to our Cookie Policy.