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;
long long mod = 1e9 + 7;
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
unsigned long long C(long long n, long long k) {
  unsigned long long res = 1;
  for (int i = n - k + 1; i <= n; ++i) res *= i;
  for (int i = 2; i <= k; ++i) res /= i;
  return res;
}
int main() {
  int t;
  t = 1;
  while (t--) {
    long long a;
    cin >> a;
    string s;
    cin >> s;
    map<long long, long long> ch;
    long long len = s.length();
    unsigned long long pre[len + 1];
    for (int i = 0; i < len; i++) {
      long long num = s[i] - '0';
      if (i == 0)
        pre[0] = num;
      else
        pre[i] = num + pre[i - 1];
      ch[pre[i]]++;
      for (int j = 0; j < i; j++) {
        ch[pre[i] - pre[j]]++;
      }
    }
    unsigned long long count = 0;
    if (a != 0) {
      for (long long j = 1; j <= sqrt(a); j++) {
        if (a % j == 0) {
          if (ch[j] && ch[a / j] && j == sqrt(a))
            count += (ch[j] * ch[a / j]);
          else if (ch[j] && ch[a / j])
            count += 2 * (ch[j] * ch[a / j]);
        }
      }
    } else if (a == 0) {
      count = ch[0] * (len * (len + 1)) - ch[0] * ch[0];
    }
    cout << count;
  }
  return 0;
}
