You have a string of decimal digits s. Let's define bij = si·sj. Find in matrix b the number of such rectangles that the sum bij for all cells (i, j) that are the elements of the rectangle equals a in each rectangle.

A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The elements of the rectangle are all cells (i, j) such that x ≤ i ≤ y, z ≤ j ≤ t.

Input

The first line contains integer a (0 ≤ a ≤ 109), the second line contains a string of decimal integers s (1 ≤ |s| ≤ 4000).

Output

Print a single integer — the answer to a problem.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

10
12345


Output

6


Input

16
439873893693495623498263984765


Output

40
#include <bits/stdc++.h>
using namespace std;
const int MAX = 4002;
int v[MAX], sum[9 * MAX], N;
char s[MAX];
int main() {
  int a;
  while (scanf("%d", &a) == 1) {
    scanf("%s", s);
    N = strlen(s), v[0] = 0;
    for (int x = 0; x < N; x++) v[x + 1] = (s[x] - '0') + v[x];
    memset(sum, 0, sizeof(sum));
    for (int x = 1; x <= N; x++)
      for (int y = x; y <= N; y++) {
        int Sxy = v[y] - v[x - 1];
        if (Sxy >= 9 * MAX || Sxy < 0) continue;
        sum[Sxy]++;
      }
    long long ans = 0LL;
    for (int x = 1; x <= N; x++)
      for (int y = x; y <= N; y++) {
        int Sxy = v[y] - v[x - 1];
        if (!a) {
          if (!Sxy)
            ans += 1ll * ((1LL * N * (N + 1LL)) / 2LL);
          else
            ans += (1LL * sum[0]);
          continue;
        }
        if (!Sxy) continue;
        if (a % Sxy || a / Sxy >= 9 * MAX) continue;
        ans += (1LL * sum[a / Sxy]);
      }
    cout << ans << endl;
  }
  return 0;
}
