Bob & His Crops

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Bob the farmer is harvesting potatoes from his long field of length N, filled with potatoes and carrots. Unfortunately, some pesky weeds have also grown in the field. Bob wants to harvest as many crops in a row, without harvesting any weeds. Can you output the number of potatoes and carrots he will harvest?

If there are multiple answers, output the one earliest in the input.

Input Specification

The first line will contain one integer, N (1 \leq N \leq 10^6), the length of Bob's field.

The next line will contain one string, containing characters p, c, or w, representing potatoes, carrots, and weeds, respectively.

Output Specification

Output the number of potatoes and carrots Bob will harvest, respectively, on one line separated by a space.

Sample Input 1

8
pccwpccc

Sample Output 1

1 3

Sample Input 2

9
wcccwwppc

Sample Output 2

0 3

Comments

There are no comments at the moment.