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;
unordered_map<int, int> m1;
unordered_map<int, int>::iterator it;
int pre[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int a, n, i, j;
  string second;
  cin >> a;
  cin.ignore(56, '\n');
  getline(cin, second);
  n = second.length();
  vector<int> zero;
  int ze = 0;
  for (i = 1; i <= n; i++) {
    pre[i] = second[i - 1] - 48;
    if (second[i - 1] == 48) zero.push_back(i);
    if (i) pre[i] += pre[i - 1];
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < i; j++) {
      int cur = pre[i] - pre[j];
      if (m1.find(cur) == m1.end())
        m1[cur] = 1;
      else
        m1[cur]++;
      if (cur == 0) ze++;
    }
  }
  long long int ans;
  if (a == 0) {
    if (m1.find(0) == m1.end())
      return cout << 0 << endl, 0;
    else {
      ans = 0;
      long long int nz = (long long int)n * (n + 1) / 2 - ze;
      ans += ze * (long long int)(nz)*2 + ze * (long long int)(ze - 1) + ze;
      return cout << ans << endl, 0;
    }
  }
  ans = 0;
  for (i = 1; i <= sqrt(a); i++) {
    if (a % i == 0) {
      if (m1.find(i) != m1.end() && m1.find(a / i) != m1.end()) {
        if (a / i != i)
          ans += 2 * (long long int)m1[i] * m1[a / i];
        else
          ans += (long long int)m1[i] * m1[a / i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
