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;
long long n;
string str;
long long pref[5005] = {0};
long long cnt[50000] = {0};
long long total = 0;
void reset() {}
void input() {
  cin >> n >> str;
  for (long long(i) = (1); (i) <= (str.length()); (i)++) {
    pref[i] = pref[i - 1] + (str[i - 1] - '0');
  }
  for (long long(i) = (1); (i) <= (str.length()); (i)++) {
    for (long long(j) = (i); (j) <= (str.length()); (j)++) {
      long long temp = pref[j] - pref[i - 1];
      cnt[temp]++;
    }
  }
}
long long Compute(long long v) { return v * (v + 1) / 2; }
void solve() {
  if (n == 0) {
    vector<long long> v;
    long long sz = 0;
    str += '$';
    for (long long(i) = (0); (i) < (str.length()); (i)++) {
      if (str[i] == '0') {
        sz++;
      } else if (sz) {
        total += Compute(sz) * Compute((long long)str.length() - 1) * 2LL -
                 Compute(sz) * Compute(sz);
        for (long long(i) = (0); (i) < (v.size()); (i)++) {
          total -= Compute(v[i]) * Compute(sz) * 2;
        }
        v.push_back(sz);
        sz = 0;
      }
    }
    cout << total << endl;
    return;
  }
  for (long long(i) = (1); (i) <= (str.length()); (i)++) {
    for (long long(j) = (i); (j) <= (str.length()); (j)++) {
      long long temp = pref[j] - pref[i - 1];
      if (temp == 0) {
        continue;
      }
      if ((n % temp) == 0 && n / temp <= 40000) {
        total += cnt[n / temp];
      }
    }
  }
  cout << total << endl;
}
void LetsRock() { solve(); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  input();
  reset();
  LetsRock();
  return 0;
}
