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;
const double EPS = 0.0000001;
const double PI = acos(-1);
const long long INFLL = 0x7FFFFFFFFFFFFFFF;
const int INF = 0x7FFFFFFF;
template <typename T>
inline void next(T &num) {
  char c;
  num = 0;
  do {
    c = getchar_unlocked();
  } while (c != EOF && c == ' ' && c == '\n' && c == '\t');
  int sign = (c == '-' ? -1 : 1);
  if (c != '-') num += (c - '0');
  while ((c = getchar_unlocked()) != EOF && c != '\n' && c != '\t' &&
         c != ' ') {
    num *= 10;
    num += (c - '0');
  }
  num *= sign;
}
inline string getstr() {
  string str;
  char k;
  while ((k = getchar_unlocked()) == ' ' || k == '\n') {
    k = getchar_unlocked();
    if (k == ' ' || k == '\n')
      continue;
    else
      break;
  }
  str.push_back(k);
  while ((k = getchar_unlocked()) != EOF && k != '\n' && k != '\t' &&
         k != '\v' && k != '\0' && k != ' ')
    str.push_back(k);
  return str;
}
const int N = 4002;
int a, sum[N], cnt[9 * N];
char s[N];
int main() {
  scanf("%d\n", &a);
  gets(s + 1);
  int len = strlen(s + 1);
  for (int i = int(1), _b = int(len); i <= _b; i++)
    sum[i] = sum[i - 1] + s[i] - '0';
  for (int i = int(1), _b = int(len); i <= _b; i++)
    for (int j = int(i), _b = int(len); j <= _b; j++)
      cnt[sum[j] - sum[i - 1]]++;
  if (a) {
    long long ans = 0;
    for (int i = int(1), _b = int(9 * len); i <= _b; i++)
      if (a % i == 0 && a / i < 9 * N) ans += (long long)cnt[i] * cnt[a / i];
    printf("%I64d", ans);
  } else
    printf("%I64d", (long long)cnt[0] * (len * (len + 1) - cnt[0]));
  return 0;
}
