Constanze's Machine
Contest: Codeforces Round 597 (Div. 2)
Difficulty rating: 1400
Tags: dp

Constanze is the smartest girl in her village but she has bad eyesight.

One day, she was able to invent an incredible machine! When you pronounce letters, the machine will inscribe them onto a piece of paper. For example, if you pronounce 'c', 'o', 'd', and 'e' in that order, then the machine will inscribe "code" onto the paper. Thanks to this machine, she can finally write messages without using her glasses.

However, her dumb friend Akko decided to play a prank on her. Akko tinkered with the machine so that if you pronounce 'w', it will inscribe "uu" instead of "w", and if you pronounce 'm', it will inscribe "nn" instead of "m"! Since Constanze had bad eyesight, she was not able to realize what Akko did.

The rest of the letters behave the same as before: if you pronounce any letter besides 'w' and 'm', the machine will just inscribe it onto a piece of paper.

The next day, I received a letter in my mailbox. I can't understand it so I think it's either just some gibberish from Akko, or Constanze made it using her machine. But since I know what Akko did, I can just list down all possible strings that Constanze's machine would have turned into the message I got and see if anything makes sense.

But I need to know how much paper I will need, and that's why I'm asking you for help. Tell me the number of strings that Constanze's machine would've turned into the message I got.

But since this number can be quite large, tell me instead its remainder when divided by $$$10^9+7$$$.

If there are no strings that Constanze's machine would've turned into the message I got, then print $$$0$$$.

Input format:
Input consists of a single line containing a string $$$s$$$ ($$$1 \leq |s| \leq 10^5$$$) — the received message. $$$s$$$ contains only lowercase Latin letters.

Output format:
Print a single integer — the number of strings that Constanze's machine would've turned into the message $$$s$$$, modulo $$$10^9+7$$$.

Constraints:
Time limit: 1.0 s
Memory limit: 256.0 MB

Note:
For the first example, the candidate strings are the following: "ouuokarinn", "ouuokarim", "owokarim", and "owokarinn".

For the second example, there is only one: "banana".

For the third example, the candidate strings are the following: "nm", "mn" and "nnn".

For the last example, there are no candidate strings that the machine can turn into "amanda", since the machine won't inscribe 'm'.

Example input:
ouuokarinn

Example output:
4

Example input:
banana

Example output:
1

Editorial:
If $$$s$$$ has any 'm' or 'w', the answer is 0. Otherwise, we can do dp.
Define $$$dp_i$$$ to be the number of strings that Constanze's machine would've turned into the first $$$i$$$ characters of $$$s$$$. Then, $$$dp_0 = dp_1 = 1$$$. For $$$i > 1$$$, transition is $$$dp_i = dp_{i - 1} + dp_{i - 2}$$$ if both $$$s_i = s_{i - 1}$$$ and $$$s_i$$$ is either 'u' or 'n', and simply $$$dp_i = dp_{i - 1}$$$ otherwise. Answer is $$$dp_{|s|}$$$.
Alternatively, notice that the maximum cardinality segment consisiting of $$$k$$$ letters 'u' or 'n' multiplies the answer by the $$$k$$$-th term of Fibonacci sequence. Thus, you can precalculate it and some sort of two iterators.