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>
#pragma GCC optimize("Ofast")
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
long long sz(vector<long long> v) {
  if (v.empty()) {
    return 0;
  } else {
    return v.size();
  }
}
long long sz(set<long long> v) {
  if (v.empty()) {
    return 0;
  } else {
    return v.size();
  }
}
long long sz(vector<pair<long long, long long> > v) {
  if (v.empty()) {
    return 0;
  } else {
    return v.size();
  }
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e % 2)
    return ((b * power((b) * (b), (e - 1) / 2)));
  else
    return power((b) * (b), e / 2);
}
long long modpower(long long b, long long e, long long q) {
  long long MOD = q;
  if (e == 0) return 1;
  if (e % 2)
    return ((b % MOD) * modpower((b % MOD) * (b % MOD), (e - 1) / 2, q)) % MOD;
  else
    return modpower((b % MOD) * (b % MOD), e / 2, q) % MOD;
}
void dpv(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << '\n';
}
void dpv(vector<pair<long long, long long> > v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << '\n';
  }
}
void dpv(set<long long> v) {
  for (auto i : v) {
    cout << i << " ";
  }
  cout << '\n';
}
void oblivious() {
  long long a;
  cin >> a;
  string s;
  cin >> s;
  long long n = s.length();
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    arr[i] = s[i] - '0';
  }
  long long sum[n + 1];
  sum[0] = 0;
  for (long long i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + arr[i];
  }
  vector<long long> y;
  vector<long long> freq(1000007, 0);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i >= j) {
        y.push_back(sum[i] - sum[j - 1]);
        freq[sum[i] - sum[j - 1]]++;
      } else {
        break;
      }
    }
  }
  sort(y.begin(), y.end());
  long long cnt = 0;
  if (a == 0) {
    cout << (2 * sz(y) - freq[0]) * freq[0] << '\n';
  } else {
    for (auto i : y) {
      if (i != 0) {
        if (a % i == 0) {
          long long z = a / i;
          if (binary_search(y.begin(), y.end(), z)) {
            cnt += freq[z];
          }
        }
      }
    }
    cout << cnt << '\n';
  }
}
signed main() {
  long long t = 1;
  while (t--) {
    oblivious();
  }
  return 0;
}
