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.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: Jovfer
 * Date: 10.11.13
 * Time: 20:32
 * To change this template use File | Settings | File Templates.
 */
public class taskA {
    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        taskA taskA = new taskA();
        taskA.open();
        taskA.solve();
        taskA.close();
    }

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String str = in.readLine();
            if (str == null) return null;
            else st = new StringTokenizer(str);
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private void close() {
        try {
            out.close();
            in.close();
        } catch (IOException ignore) {
        }
    }

    int n, m;
    int[] a;

    private void solve() throws IOException {
        int a = nextInt();
        char[] inp = nextToken().toCharArray();
        int n = inp.length;
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = inp[i] - '0';
        }
        int[] sum = new int[n + 1];
        sum[0] = 0;
        for (int i = 0; i < n; i++) {
            sum[i + 1] = sum[i] + s[i];
        }
        HashMap<Integer, Integer> sums = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                int key = sum[j] - sum[i - 1];
                sums.put(key, 1 + (sums.containsKey(key) ? sums.get(key) : 0));
            }
        }

        long answ = 0;
        if (a != 0) {
            for (int first = 1; first * first <= a; first++) {
                if (a % first != 0) continue;
                int second = a / first;
                answ += (first != second ? 2L : 1L) * (sums.containsKey(first) ? sums.get(first) : 0) * (sums.containsKey(second) ? sums.get(second) : 0);
            }
        } else {
            long zero = sums.containsKey(0) ? sums.get(0) : 0;
            if (zero > 0) {
                answ = zero * zero;
                for (Integer key : sums.keySet()) {
                    if (key == 0) continue;
                    answ += zero * 1L * sums.get(key) * 2;
                }
            }
        }

        out.println(answ);


    }

    private void open() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new BufferedOutputStream(System.out));
    }

}