Yet Another Expression Mining

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

문제

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

Count the number of subsequences of SS 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 AA.

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.

SS

AA

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

출력

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