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 mod = 1000000007;
int binp(vector<long long> a, long long b) {
  int l = 0, r = a.size() - 1;
  if (b == a[r]) return r;
  while (l + 1 < r) {
    if (b == a[l]) return l;
    if (a[(l + r) / 2] > b)
      r = (l + r) / 2;
    else
      l = (l + r) / 2;
  }
  if (b == a[l]) return l;
  if (b == a[r]) return r;
}
long long probifanull(string s) {
  long long ans = 0;
  int n = s.length();
  for (int l = 0; l < n; ++l) {
    if (s[l] == '0')
      ++ans;
    else
      continue;
    for (int r = l + 1; r < n; ++r) {
      if (s[r] == '0')
        ++ans;
      else
        break;
    }
  }
  return 2 * ans * ((n * (n + 1)) / 2 - ans) + ans * ans;
}
int main() {
  string s;
  long long a;
  cin >> a;
  cin >> s;
  if (a == 0) {
    cout << probifanull(s) << endl;
    return 0;
  }
  vector<long long> del(0);
  for (long long i = 1; i * i <= a; ++i) {
    if (a % i == 0) {
      del.push_back(i);
      if (i * i != a) del.push_back(a / i);
    }
  }
  sort(del.begin(), del.end());
  ;
  long long m = del.size();
  vector<long long> kilk(m);
  for (long long i = 0; i < m; ++i) kilk[i] = 0;
  int n = s.length();
  long long sum;
  for (int l = 0; l < n; l++) {
    sum = (int(s[l]) - 48);
    if (sum && a % sum == 0) {
      ++kilk[binp(del, sum)];
    }
    for (int r = l + 1; r < n; ++r) {
      sum += (int(s[r]) - 48);
      if (sum && a % sum == 0) {
        ++kilk[binp(del, sum)];
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= m; ++i) ans += kilk[i - 1] * kilk[m - i];
  cout << ans << endl;
}
