You are on page 1of 1

Unexpected Problem

Marc is young lover of strings who wants your help with the following problem. Given a string, , of
lowercase English alphabetic letters and an integer, , calculate the number of string 's such that:
Each

consists of lowercase English alphabetic letters

, meaning their concatenation is commutative.


Print the number of string 's modulo

Input Format
The first line contains a string denoting .
The second line contains an integer denoting

Constraints

consists of lowercase English alphabetic letters only (i.e.,

to ).

Output Format
Print the number of string 's satisfying the conditions above, modulo

Sample Input
abc
6

Sample Output
2

Explanation
Given

abc , we have two possible string 's satisfying

1.

abc

2.

abcabc .

Thus, we print

on a new line.

and

You might also like