
Dankey Kang, Croneria's most fearsome villain, has decided to increase the size of his gang by creating many clone soldiers. Each clone can be one of two types, type 0
or type 1
.
There are two possible methods of cloning, which can be described as a string of clone types 0
and 1
.
Initially, there is one clone of type 0
in the line. Then, the following process will continue indefinitely:
- The first clone in the line will leave the front of the line to fight.
- If that clone's type is
0
, a string of clones matching will be added to the end of the line, in order. - If that clone's type is
1
, a string of clones matching will be added to the end of the line, in order.
Dankey Kang is then interested in
Constraints
For all subtasks:
Subtask | Points | Additional Constraints |
---|---|---|
1 | 5 | |
2 | 15 | |
3 | 20 | |
4 | 25 | |
5 | 25 | |
6 | 10 | No additional constraints. |
Input Specification
The first line will contain string
The second line will contain string
The third line will contain the integer
On the next
Output Specification
Output
Sample Input
100
10
9
1
2
3
4
5
6
7
8
9
Sample Output
0
1
0
0
1
0
1
0
0
Comments