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 toInt(string s) {
  int sum = 0;
  for (int i = 0; i < s.length(); i++) {
    sum = sum * 10 + s[i] - '0';
  }
  return sum;
}
int arr[4005];
int sums[4005];
int main() {
  string s;
  getline(cin, s);
  int a = toInt(s);
  getline(cin, s);
  int len = s.length();
  for (int i = 0; i < len; i++) {
    arr[i] = s[i] - '0';
    if (i == 0) {
      sums[i] = arr[i];
    } else {
      sums[i] = sums[i - 1] + arr[i];
    }
  }
  map<long long, long long> m;
  m[0] = 0;
  long long count = 0;
  for (int i = 0; i < len; i++) {
    for (int j = i; j < len; j++) {
      int sum = sums[j] - ((i == 0) ? 0 : sums[i - 1]);
      if (sum == 0 || a % sum == 0) {
        if (m.find(sum) == m.end()) {
          m[sum] = 1;
        } else {
          m[sum]++;
        }
        if (sum != 0) count++;
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i * i <= a; i++) {
    if (a % i == 0) {
      long long j = a / i;
      if (m.find(i) != m.end() && m.find(j) != m.end()) {
        if (i == j)
          ans = ans + (m[i] * m[j]);
        else
          ans = ans + 2 * (m[i] * m[j]);
      }
    }
  }
  if (a == 0) {
    ans = m[0] * m[0] + 2 * m[0] * count;
  }
  cout << ans << endl;
}
