#agc046c. [agc046_c]Shift
[agc046_c]Shift
Problem Statement
Given is a string consisting of 0
and 1
. Find the number of strings, modulo , that can result from applying the following operation on between and times (inclusive):
- Choose a pair of integers such that the -th and -th characters of are
0
and1
, respectively. Remove the -th character from and insert it to the immediate left of the -th character.
Constraints
- consists of
0
and1
.
Input
Input is given from Standard Input in the following format:
Output
Find the number of strings, modulo , that can result from applying the operation on between and times (inclusive).
Sample Input 1
0101 1
Sample Output 1
4
Four strings, 0101
, 0110
, 1001
, and 1010
, can result.
Sample Input 2
01100110 2
Sample Output 2
14
Sample Input 3
1101010010101101110111100011011111011000111101110101010010101010101 20
Sample Output 3
113434815