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 power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
const int N = 1e5 + 7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};
const long double PI = acos(-1.0);
const double EPS = 1e-9;
string s;
long long a, n, sum[4007], ans;
map<long long, long long> m;
void solve() {
  cin >> a >> s;
  n = s.size();
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + s[i - 1] - '0';
  long long t = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      long long psum = sum[j] - sum[i - 1];
      m[psum]++;
      t++;
    }
  for (auto i : m) {
    long long psum = i.first;
    if (psum != 0 && a != 0 && a % psum == 0) {
      long long cur = m[a / psum] * i.second;
      ans += cur;
    }
    if (a == 0) {
      if (psum == 0)
        ans += m[psum] * t;
      else
        ans += m[psum] * m[0];
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
