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
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C365C {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] digits = Arrays.stream(sc.next().split("")).mapToInt(Integer::valueOf).toArray();
        sc.close();

        PrintWriter out = new PrintWriter(System.out);
        out.println(solve(a, digits));
        out.close();
    }

    private static long solve(int a, int[] digits) {
        int len = digits.length;
        int[] prefixSum = getPrefixSum(digits);
        Map<Integer, Long> sumCounter = getSumFrequency(digits, prefixSum);

        if (a == 0) {
            long numOfSum0 = sumCounter.getOrDefault(0, 0L);
            return numOfSum0 * len * (1 + len) - numOfSum0 * numOfSum0;
        }

        long count = 0;
        for (int sum1 = 1; sum1 <= prefixSum[len - 1]; sum1++) {
            if (a % sum1 == 0 && a / sum1 <= prefixSum[len - 1]) {
                count += sumCounter.getOrDefault(sum1, 0L) * sumCounter.getOrDefault(a / sum1, 0L);
            }
        }
        return count;
    }

    private static Map<Integer, Long> getSumFrequency(int[] digits, int[] prefixSum) {
        Map<Integer, Long> sumCounter = new HashMap<>();
        int len = digits.length;
        for (int i = 0; i < len; i++) {
            for (int j = i; j < len; j++) {
                int sumOfItoJ = prefixSum[j] - prefixSum[i] + digits[i];
                sumCounter.compute(sumOfItoJ, (k, v) -> v == null ? 1L : v + 1L);
            }
        }
        return sumCounter;
    }

    private static int[] getPrefixSum(int[] digits) {
        int len = digits.length;
        int[] sum = new int[len];
        sum[0] = digits[0];
        for (int i = 1; i < len; i++) {
            sum[i] = digits[i] + sum[i - 1];
        }
        return sum;
    }
}