atcoder#ABC299F. [ABC299F] Square Subsequence

[ABC299F] Square Subsequence

Score : 500500 points

Problem Statement

You are given a string SS consisting of lowercase English letters. Print the number of non-empty strings TT that satisfy the following condition, modulo 998244353998244353.

The concatenation TTTT of two copies of TT is a subsequence of SS (not necessarily contiguous).

Constraints

  • SS is a string consisting of lowercase English letters whose length is between 11 and 100100, inclusive.

Input

The input is given from Standard Input in the following format:

SS

Output

Print the answer.

ababbaba
8

The eight strings satisfying the condition are a, aa, ab, aba, b, ba, bab, and bb.

zzz
1

The only string satisfying the condition is z. Note that this string contributes to the answer just once, although there are three ways to extract the subsequence zz from S=S1S2S3=S = S_1S_2S_3 = zzz: S1S2=S_1S_2 = zz, S1S3=S_1S_3 = zz, and S2S3=S_2S_3 = zz.

ppppqqppqqqpqpqppqpqqqqpppqppq
580