Under construction

Still being built. Things may change

Namomo Subsequence

Time limit3sMemory limit1024 MB

Summary
Count the length-6 subsequences of s whose equal-character pattern matches
Level

Medium5 of 10

Topics
String, Dynamic programming, Hash map
Solved
No attempts yet

Problem

"gshfd1jkhaRaadfglkjerVcvuy0gf" said Prof. Pang.

To understand Prof. Pang's word, we would like to calculate the number of namomo subsequences of it. The word by Prof. Pang is a string ss with nn characters, where each character is either an English letter (lowercase or uppercase) or a digit. The ii-th character of ss is denoted s[i]s[i] (1≤i≤n1 \le i \le n). A subsequence tt of ss is defined by a list of indices t1,…,t6t_1, \ldots, t_6 such that 1≤t1<t2<…<t6≤n1 \le t_1 < t_2 < \ldots < t_6 \le n. Let compare(c1,c2)compare(c_1, c_2) be a function on two characters such that compare(c1,c2)=1compare(c_1, c_2) = 1 when c1=c2c_1 = c_2 and compare(c1,c2)=0compare(c_1, c_2) = 0 otherwise. tt is a namomo subsequence of ss if and only if for any 1≤i<j≤61 \le i < j \le 6, compare(s[ti],s[tj])=compare(namomo[i],namomo[j])compare(s[t_i], s[t_j]) = compare(namomo[i], namomo[j]), where namomo[x]namomo[x] is the xx-th character of the string "namomo" (1≤x≤61 \le x \le 6).

Output the number of namomo subsequences of a given string ss modulo 998244353998244353.

Input

The first line contains a string ss with nn characters (6≤n≤10000006 \le n \le 1000000). ss contains only lowercase English letters ('a' to 'z'), uppercase English letters ('A' to 'Z'), and digits ('0' to '9').

Output

Output one integer, the answer modulo 998244353998244353.

Examples4

  1. Example 1

    Input
    wohaha
    
    Expected output
    1
    
  2. Example 2

    Input
    momomo
    
    Expected output
    0
    
  3. Example 3

    Input
    gshfd1jkhaRaadfglkjerVcvuy0gf
    
    Expected output
    73
    
  4. Example 4

    Input
    retiredMiFaFa0v0
    
    Expected output
    33