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 s[4000 + 1];
int v[4000];
char str[4000 + 10];
char *trim_line(char *str) { return strtok(str, "\r\n"); }
int solve_problem() {
  map<int, long long> numbers;
  int a;
  if (fgets(str, sizeof(str), stdin) == NULL) return 1;
  a = atoi(str);
  if (fgets(str, sizeof(str), stdin) == NULL) return 1;
  char *p = trim_line(str);
  size_t n = strlen(str);
  for (size_t i = 0; i < n; i++) v[i] = p[i] - '0';
  s[0] = 0;
  for (size_t i = 0; i < n; i++) s[i + 1] = s[i] + v[i];
  for (size_t i = 0; i < n; i++)
    for (size_t j = i + 1; j <= n; j++) ++numbers[s[j] - s[i]];
  long long result = 0;
  if (a == 0) {
    long long total = 0;
    for (map<int, long long>::iterator it = numbers.begin();
         it != numbers.end(); ++it)
      total += it->second;
    long long other = total - numbers[0];
    result = total * total - other * other;
  } else {
    numbers.erase(0);
    map<int, long long>::reverse_iterator r_it = numbers.rbegin();
    for (map<int, long long>::iterator it = numbers.begin();
         it != numbers.end(); ++it) {
      while (r_it != numbers.rend() && it->first * r_it->first > a) ++r_it;
      if (r_it == numbers.rend()) break;
      if (it->first * r_it->first == a) result += it->second * r_it->second;
    }
  }
  cout << result << endl;
  return 0;
}
int main() {
  solve_problem();
  return 0;
}
