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 gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int a;
char str[4005];
int cum[4005];
map<int, int> mpv;
int main() {
  scanf("%d", &a);
  scanf("%s", str + 1);
  int len = strlen(str + 1);
  for (int i = (1); i <= (len); ++i) {
    cum[i] = cum[i - 1] + str[i] - '0';
  }
  for (int i = (1); i <= (len); ++i) {
    for (int j = (i); j <= (len); ++j) {
      int rangeSum = cum[j] - cum[i - 1];
      mpv[rangeSum] = mpv[rangeSum] + 1;
    }
  }
  unsigned long long ans = 0;
  for (typeof(mpv.begin()) i = mpv.begin(); i != mpv.end(); ++i) {
    int num = i->first;
    int cnt = i->second;
    if (num > a)
      break;
    else if (num == 0) {
      if (a == 0) {
        unsigned long long factor = ((len) * (unsigned long long)(len + 1)) / 2;
        ans += 2 * cnt * factor - (cnt * (unsigned long long)cnt);
      }
    } else {
      int val = a / num;
      if ((a % num == 0)) {
        map<int, int>::iterator it = mpv.find(val);
        if (it != mpv.end()) {
          ;
          ans += (unsigned long long)mpv[val] * cnt;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
