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 comment(linker, "/stack:64000000")
using namespace std;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
template <class T>
T jog(T a, T b) {
  return a + b;
}
template <class T>
T bog(T a, T b) {
  return a - b;
}
template <class T>
T gon(T a, T b) {
  return a * b;
}
template <class T>
T sq(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <class T>
T power(T a, T p) {
  T res = 1, x = a;
  while (p) {
    if (p & 1) res = res * x;
    x = x * x;
    p >>= 1;
  }
  return res;
}
template <class T>
T cordinatlenth(T a, T b, T c, T d) {
  return sqrt(sq(a - c) + sq(b - d));
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
long long bigmod(long long a, long long p, long long mod) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    p >>= 1;
  }
  return res;
}
int diraction1[] = {-1, 0, 0, 1, 1, -1, -1, 1};
int diraction2[] = {0, -1, 1, 0, 1, -1, 1, -1};
int horsed1[] = {-2, -2, -1, 1, 2, 2, 1, -1};
int horsed2[] = {1, -1, -2, -2, -1, 1, 2, 2};
void Input();
const int INF = 2147483647;
const long long LINF = 9223372036854775807ll;
long long a, sum[1111111], ans;
string str;
int main() {
  Input();
  return 0;
}
void Input() {
  cin >> a >> str;
  ans = 0;
  int len = str.size();
  memset(sum, 0, sizeof(sum));
  for (int i = 0; i < len; i++) {
    int tot = 0;
    for (int j = i; j < len; j++) {
      tot += (str[j] - '0');
      sum[tot]++;
    }
  }
  if (a == 0) {
    ans = len * (len + 1) / 2;
    ans = sum[0] * ans + sum[0] * ans - sum[0] * sum[0];
  } else {
    for (int i = 1; i < 4000 * 20; i++) {
      if (!sum[i]) continue;
      if (a % i == 0 && a / i < 4000 * 20) {
        ans += sum[i] * sum[a / i];
      }
    }
  }
  cout << ans << endl;
}
