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 main() {
  ios::sync_with_stdio(false);
  long long a, b, c, i, j, k, l, m, t, x, y, n, z;
  string s;
  map<long long, long long> mp;
  map<long long, long long>::iterator it;
  cin >> a >> s;
  n = s.size();
  long long a1[n + 1];
  a1[0] = 0;
  for (i = 1; i < n + 1; i++) a1[i] = s[i - 1] - '0' + a1[i - 1];
  for (i = 0; i < n + 1; i++) {
    for (j = i + 1; j < n + 1; j++) {
      mp[a1[j] - a1[i]]++;
    }
  }
  c = 0;
  if (!a) c = (mp[0] * (n * (n + 1) - mp[0]));
  if (!a) {
    cout << c << endl;
    return 0;
  }
  for (i = 0; i < n + 1; i++) {
    for (j = i + 1; j < n + 1; j++) {
      if (a1[j] - a1[i] != 0)
        if (a % (a1[j] - a1[i]) == 0) {
          it = mp.find(a / (a1[j] - a1[i]));
          if (it != mp.end()) c = c + mp[a / (a1[j] - a1[i])];
        }
    }
  }
  cout << c << endl;
  return 0;
}
