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, m;
char t[4005];
int s[4005];
int a[4005 * 4005];
int b[4005 * 4005];
int num[4005 * 4005];
long long cnt;
int check(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++) a[m++] = (s[j] - s[i - 1]);
  sort(a, a + m);
  int j = 0, len = 0;
  while (j < m) {
    b[len] = a[j];
    num[len] = 1;
    while (j + 1 < m && a[j + 1] == a[j]) {
      num[len]++;
      j++;
    }
    len++;
    j++;
  }
  swap(len, m);
  if (A == 0) {
    if (b[0] == 0)
      cnt = 2ll * num[0] * (1ll * n * (n + 1) / 2 - num[0]) +
            1ll * num[0] * num[0];
  } else
    for (int i = 0; i < m; i++)
      if (b[i] != 0 && A % b[i] == 0) {
        int x = A / b[i];
        cnt += 1ll * check(x) * num[i];
      }
  cout << cnt;
  return 0;
}
