LCS 8

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

You are given a string SS of length NN, consisting of uppercase letters, and a small nonnegative integer KK.

Please compute the number of strings TT of length NN, consisting of only uppercase letters, such that the longest common subsequence of SS and TT has length at least NKN - K. As the number could be large, print the number of such strings modulo 109+710^9 + 7.

A string S=s_1s_2s_nS = s\_1s\_2\ldots s\_n is a subsequence of a string T=t_1t_2t_mT = t\_1t\_2\ldots t\_m if there exists an increasing sequence of indices 1i_1<i_2< <i_nm1 \le i\_1 < i\_2 <  \ldots < i\_n \le m such that s_x=t_i_xs\_x = t\_{i\_x} for all 1xn1 \le x \le n.

입력

The first line of the input contains the length-NN string SS (1S50,0001 \le |S| \le 50\\,000). All characters of SS are uppercase letters.

The next line of the input contains the single integer KK (0K3)0 \le K \le 3).

출력

Print the number of such strings modulo 109+710^9 + 7.