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 N = 4005;
const int S = 1e6 + 10;
int x, n;
int a[N], pref[N];
int cnt[S];
char b[N];
void get() {
  scanf("%s", b);
  n = strlen(b);
  for (int i = 0; i < n; i++) a[i] = b[i] - '0';
}
long long r(int h, int w) { return 1LL * w * (w + 1) * h * (h + 1) / 4; }
int main() {
  scanf("%d", &x);
  get();
  pref[0] = a[0];
  for (int i = 1; i < n; i++) pref[i] = pref[i - 1] + a[i];
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      int z = pref[j];
      if (i > 0) z -= pref[i - 1];
      cnt[z]++;
    }
  if (x == 0) {
    long long z = 0;
    int i = 0;
    vector<int> seg;
    while (i < n) {
      int j = i;
      while (j < n && a[j] == a[i]) j++;
      if (!a[i]) {
        z += 2 * r(n, j - i);
        seg.push_back(j - i);
      }
      i = j;
    }
    for (int ii = 0; ii < (int)seg.size(); ii++)
      for (int jj = 0; jj < (int)seg.size(); jj++) z -= r(seg[ii], seg[jj]);
    return printf("%lld\n", z), 0;
  }
  long long ans = 0;
  for (int i = 1; i < S; i++)
    if (x % i == 0) ans += 1LL * cnt[i] * (x / i >= S ? 0 : cnt[x / i]);
  printf("%lld\n", ans);
  return 0;
}
