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

public class Main
{
    public static void main(String[] args) throws Exception
    {
        StringBuilder resBuilder = new StringBuilder();

        new Program(new FastBufferReader(FastBufferReader.CONSOLE), resBuilder).run();

        System.out.print(resBuilder);
    }
}

class FastBufferReader
{
    private BufferedReader bufferedReader;
    private StringTokenizer tokenizer;

    public static final int CONSOLE = 0;
    public static final int FILE = 1;

    public FastBufferReader(int source) throws Exception
    {
        if (source == CONSOLE)
        {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }
        else if (source == FILE)
        {
            bufferedReader = new BufferedReader(new FileReader(new File("c:\\a.txt")));
            tokenizer = null;
        }
        else
            throw new Exception();
    }

    public String nextToken()
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            try
            {
                tokenizer = new StringTokenizer(bufferedReader.readLine());
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

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

class Program
{
    private final FastBufferReader in;
    private final StringBuilder resBuilder;

    public Program(FastBufferReader in, StringBuilder resBuilder)
    {
        this.in = in;
        this.resBuilder = resBuilder;
    }

    void run()
    {
        int a = in.nextInt();

        char[] arr = in.nextToken().toCharArray();

        int n = arr.length;

        long[] cuml = new long[n + 1];

        cuml[0] = 0;

        for (int i = 1; i <= n; i++)
            cuml[i] = cuml[i - 1] + arr[i - 1] - 48;

        HashMap<Long, Long> occ = new HashMap<Long, Long>();

        for (int i = 1; i <= n; i++)
            for (int j = i; j <= n; j++)
            {
                long sum = consecutiveSum(cuml, i, j);

                if (sum == 0 || a % sum == 0)
                {
                    Long occurence = occ.get(sum);
                    occ.put(sum, occurence == null ? 1 : occurence + 1);
                }
            }

        long sol = 0;

        if (a != 0)
        {
            occ.remove(0);

            for (int i = 1; i <= n; i++)
                for (int j = i; j <= n; j++)
                {
                    long sum = consecutiveSum(cuml, i, j);

                    if (sum != 0 && a % sum == 0)
                    {
                        Long occurence = occ.get(a / sum);

                        if (occurence != null)
                            sol += occurence;
                    }
                }
        }
        else
        {
            for (int i = 1; i <= n; i++)
                for (int j = i; j <= n; j++)
                {
                    long sum = consecutiveSum(cuml, i, j);

                    if (sum == 0)
                        sol += ((long) n) * (n + 1) / 2;
                    else
                    {
                        Long occurence = occ.get(a / sum);

                        if (occurence != null)
                            sol += occurence;
                    }
                }
        }

        resBuilder.append(sol).append("\n");
    }

    private static long consecutiveSum(long[] cuml, int i, int j)
    {
        return cuml[j] - cuml[i - 1];
    }
}
