시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB0000.000%

문제

You are given an integer $A$ and a string $S$ which consists of the following 10 characters: an addition operator '+', a digit '1', '2', ... , '9'.

Count the number of subsequences of $S$ which satisfy the following conditions.

  • The subsequence is not empty.
  • The first letter of the subsequence is not '+'.
  • The last letter of the subsequence is not '+'.
  • '+' does not appear consecutively in the subsequence.
  • Reading the subsequence as a mathematical expression, its evaluation result is $A$.

Note that a subsequence is a sequence that can be obtained from the given sequence by removing zero or more elements without changing the order of the remaining elements.

Two subsequences are considered different if the set of removed elements' indices are different.

입력

The input consists of a single test case in the format below.

$S$

$A$

The first line contains a single string $S$ ($1 \le |S| \le 36$). Each character of $S$ is either '+', or a digit between '1' and '9'. The second line contains a single integer $A$ ($1 \le A \le 10^{18}$).

출력

Output the number of subsequences which satisfy the given conditions in a single line.

예제 입력 1

1+2+3+4+5+6
18

예제 출력 1

9

예제 입력 2

+391+49++21+9934
43

예제 출력 2

47

예제 입력 3

1111111111111111
1111111111

예제 출력 3

8008