P1321 Word Overlay Restoration
Description
I have a string of length $l$, which initially consists of $l$ periods ('.').
I repeatedly paste the words `boy` or `girl` onto this string in order.
Words pasted later will overwrite previously pasted words or periods. In the end, each word has at least one character that is not overwritten.
How many `boy` and how many `girl` were pasted in total?
Input Format
A single line: the string after repeatedly pasting the words `boy` and `girl`.
Output Format
Two lines, each with one integer. The first line is the count of `boy`, and the second line is the count of `girl`.
Explanation/Hint
It is guaranteed that $3\le l\le255$, and the string contains only the following characters: $\texttt{.bgilory}$.
Translated by ChatGPT 5