Under construction

Still being built. Things may change

Anonymous M and Call Signs

Time limit1sMemory limit1024 MB

Summary
Given a concert transcript, count how many lead call signs are shouted and how many of the five fixed sets end, following the set order and the greedy repeat rule for set A.
Level

Medium4 of 10

Topics
Simulation, String, Implementation
Solved
No attempts yet

Problem

KPSC member Captain attended Anonymous M's concert in Tokyo on August 30, 2024. At this concert, the audience cheered for Anonymous M by shouting groups of space-separated words called call signs. Each group of call signs is called a set. The sets used at this concert are as follows.

  • Set A: [se] no hai- hai- hai hai hai hai (u- hai) * n
  • Set B: [mik-jjang] kawaii!
  • Set C: [Are] you ready antena senku high!
  • Set D: u- hai
  • Set E: hai

When a set is performed, its words are called in the order given by the set list. These called words are the call signs. In sets A, B, and C, the call signs in square brackets are leads, which are shouted loudly on their own. The cheering follows these rules:

  • The concert starts with no set in progress.

  • While a set is in progress:

    • No part of a set is skipped, and no set is cut off before it ends.

    • Noise (other words) may appear during a set. Noise is not part of the current set and is ignored.

      • Noise can be any word except the first call sign of each set.
    • If the current set is not set A:

      • When the last call sign of the current set is called, the set ends.
    • If the current set is set A:

      • In set A, "(u- hai) * n" means the call sign u- hai is repeated one or more times. It is repeated the maximum possible number of times.
        • Sets D and E are not performed in this part.
      • If the first call sign of a set other than D is called after the hai of "(u- hai) * n", set A ends. Another set starts at the same moment set A ends.
      • If the concert ends after the hai of "(u- hai) * n", set A ends.
  • While no set is in progress:

    • If the first call sign of a set is called, that set is performed.
    • Any other word is treated as noise and ignored.

Input

The first line contains a string SS. SS consists of uppercase and lowercase English letters, spaces (" "), and the special characters "!" and "-". Two spaces never appear consecutively.

Output

Print the number of leads called and the number of sets that ended, separated by a space.

Constraints

  • 1≤∣S∣≤100 0001 \le |S| \le 100\,000

Examples4

  1. Example 1

    Input
    Monsters u- hai might u- hai be a scary foe to fight
    
    Expected output
    0 2
    
  2. Example 2

    Input
    Are you ready antena senku high! Wanna shinshou kou nekkyou e meimei Friday Night!
    
    Expected output
    1 1
    
  3. Example 3

    Input
    kobamu you ni se saketa no kimi hai- wa hai- naze hai naiteru hai no hai hai u- obienagara hai u- motometeita hai
    
    Expected output
    1 1
    
  4. Example 4

    Input
    hai- hai- hai hai hai hai u- hai u hai
    
    Expected output
    0 6