Wolves and Proper Words

Given a word of w, o, l, f, decide whether it is a concatenation of blocks w^n o^n l^n f^n for n >= 1.

Medium4StackGreedyInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

The wolf country uses these rules to decide whether a word is proper.

  1. For a positive integer nn, the word made of "w" repeated nn times, then "o" repeated nn times, then "l" repeated nn times, then "f" repeated nn times is proper.
  2. The concatenation of two proper words is proper.
  3. Only the words built by the two rules above are proper.

Here are some examples.

  • "wolf", "wwoollff" and "wwwooolllfff", all built by rule 1, are proper.
  • "wolfwwoollff", built by rule 2, is proper.
  • "wolfwwoollffwolf", built by applying rule 2 twice, is proper.
  • "wfol" is not proper because the letters are in the wrong order.
  • "wwolfolf" is not proper because another string sits in the middle of a word.
  • "wwwoolllfff" is not proper because "o" appears only twice.

Given one word, decide whether it is proper.

Input

The first line contains a word. The word consists only of "w", "o", "l" and "f", and its length is between 1 and 50.

Output

Print 1 if the given word is proper, and 0 otherwise.