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;
template <typename T>
inline void read(vector<T> &A) {
  for_each(A.begin(), A.end(), [&](T &i) { cin >> i; });
}
template <typename T>
inline void print(const vector<T> &A, const string &sep = " ",
                  const string &delim = "\n") {
  for_each(A.begin(), A.end(), [&](const T &i) { cout << i << sep; });
  cout << delim;
}
const size_t MOD = 1e9 + 7;
const size_t MAXA = 1e9;
const size_t MAXN = 2 * 1e5 + 1;
const double delta = 0.000001;
long long N, K, ans = 0;
string S;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> K >> S;
  N = S.size();
  vector<long long> A(N), prefix_sum(N + 1);
  map<long long, long long> range_cnt;
  for (int i = 0; i < N; i++) A[i] = S[i] - '0';
  partial_sum((A).begin(), (A).end(), prefix_sum.begin() + 1);
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= N; j++) range_cnt[prefix_sum[j] - prefix_sum[i]]++;
  }
  if (K) {
    for (int i = 1; i < sqrt(K); i++) {
      if (K % i) continue;
      ans += 2 * range_cnt[i] * range_cnt[K / i];
    }
    if (int x = sqrt(K); x * x == K) ans += range_cnt[x] * range_cnt[x];
  } else
    ans = range_cnt[0] * N * (N + 1) - range_cnt[0] * range_cnt[0];
  cout << ans << '\n';
  return 0;
}
