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;
int A, n;
char t[4005];
int s[4005];
int a[4005 * 4005], len;
int b[4005 * 4005], m;
long long num[4005 * 4005];
long long cnt, tot, n0;
int get(int x) {
  if (x < b[0] || b[m - 1] < x) return 0;
  int l = 0, r = m - 1, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (b[mid] == x) {
      break;
    } else if (b[mid] < x)
      l = mid + 1;
    else
      r = mid - 1;
  }
  if (b[mid] != x) return 0;
  return num[mid];
}
int main() {
  scanf("%d\n", &A);
  scanf("%s", t + 1);
  n = strlen(t + 1);
  s[0] = 0;
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + (t[i] - '0');
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      if (s[j] - s[i - 1] == 0) n0++;
      a[len++] = (s[j] - s[i - 1]);
    }
  sort(a, a + len);
  int j = 0;
  m = 0;
  while (j < len) {
    int i = j;
    while (j + 1 < len && a[j + 1] == a[j]) {
      j++;
    }
    if (a[j] != 0 && A % a[j] == 0) {
      b[m] = a[j];
      num[m] = j - i + 1;
      m++;
    }
    j++;
  }
  tot = 1ll * n * (n + 1) / 2;
  if (A == 0) {
    if (n0 > 0) cnt = 2ll * n0 * (tot - n0) + n0 * n0;
  } else
    for (int i = 0; i < m; i++) {
      int x = A / b[i];
      cnt += 1ll * num[i] * get(x);
    }
  cout << cnt;
  return 0;
}
