2020 NA Regionals Practice Contest 5


2021-01-16 09:00 AKST

2020 NA Regionals Practice Contest 5


2021-01-16 14:00 AKST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -156 days 22:18:53

Time elapsed


Time remaining


Problem H

Returning to the Beautiful Gloomy Outback (BGO) after a strenuous trip to the city, you hear a faint howl in the distance. Instantly you realize it is your friend Fenrir inviting you to a howling contest.

In order to make an impressive howl that wins the contest, you know that your howl must fulfill the following criteria in order to be valid:

  • It must consist of a combination of the letters A, H, O and W. Each letter must occur at least once.

  • The howl can not contain two consecutive W’s, or two consecutive H’s.

  • The howl can not contain an H followed immediately by a W or an A.

  • There can never be an A after the first occurrence of an O.

Can you produce a longer howl than Fenrir and win the contest?


The first and only line of input contains a single word, the howl of Fenrir. Since Fenrir is a proper wolf, his howls are always valid. Writing down Fenrir’s howl will require at most $1$ MB of computer memory.


A valid howl which will win the howling contest.

Sample Input 1 Sample Output 1