atcoder#AGC027E. [AGC027E] ABBreviate

[AGC027E] ABBreviate

Score : 13001300 points

Problem Statement

There is a string ss consisting of a and b. Snuke can perform the following two kinds of operation any number of times in any order:

  • Choose an occurrence of aa as a substring, and replace it with b.
  • Choose an occurrence of bb as a substring, and replace it with a.

How many strings ss can be obtained by this sequence of operations? Find the count modulo 109+710^9 + 7.

Constraints

  • 1s1051 \leq |s| \leq 10^5
  • ss consists of a and b.

Input

Input is given from Standard Input in the following format:

ss

Output

Print the number of strings ss that can be obtained, modulo 109+710^9 + 7.

aaaa
6

Six strings can be obtained:

  • aaaa
  • aab
  • aba
  • baa
  • bb
  • a
aabb
5

Five strings can be obtained:

  • aabb
  • aaa
  • bbb
  • ab
  • ba
ababababa
1

Snuke cannot perform any operation.

babbabaaba
35