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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class C {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException
    {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = null;
        long a = nextLong();
        char[] s = nextToken().toCharArray();
        long[] sum = new long[s.length + 1];
        sum[0] = 0;
        for (int i = 0; i < s.length; i++)
            sum[i + 1] = sum[i] + s[i] - '0';
        HashMap<Long, Long> hashSum = new HashMap<Long, Long>();
        for (int i = 0; i < s.length; i++)
            for (int j = i + 1; j <= s.length; j++)
            {
                long cur = sum[j] - sum[i];
                Long prev = hashSum.get(cur);
                if (prev == null)
                    prev = 0l;
                hashSum.put(cur, prev + 1);
            }
        long ret = 0;
        for (int i = 0; i < s.length; i++)
            for (int j = i + 1; j <= s.length; j++)
            {
                long cur = sum[j] - sum[i];
                if ((cur > 0 && a % cur == 0) || a == 0)
                {
                    if (a == 0 && cur == 0)
                        ret += (s.length)*(s.length+1)/2;
                    else
                    {
                        Long cnt = hashSum.get(a / cur);
                        if (cnt != null)
                            ret += cnt;
                    }
                }
            }
        System.out.println(ret);
    }

    static BufferedReader reader;
    static StringTokenizer tokenizer;

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

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

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

    static String nextToken() throws IOException
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}
