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
/**
 * Created by Anna.Skobaneva on 1/19/14.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.Arrays;

public class TaskC {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        TaskC solver = new TaskC();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: "
                    + (System.currentTimeMillis() - time));
            System.out.println("Memory: "
                    + (Runtime.getRuntime().totalMemory() - Runtime
                    .getRuntime().freeMemory()));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        //in = new BufferedReader(new FileReader("input.txt"));
        //out = new PrintWriter(new FileWriter("output.txt"));
    }

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

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

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

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

    boolean hasMoreTokens() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null)
                return false;
            st = new StringTokenizer(line);
        }
        return true;
    }

    public void solve() throws NumberFormatException, IOException {
        long a = nextLong();
        char[] source = in.readLine().toCharArray();
        int length = source.length;
        byte[] sourceDigits = new byte[length];
        for (int i = 0; i < length; i++) {
            sourceDigits[i] = (byte) (source[i] - '0');
        }

        int sumOfLength = 9 * length;
        int[] count = new int[sumOfLength + 1];
        Arrays.fill(count, 0);

        int[][] sum = new int[length][length];
        for (int i = 0; i < length; i++) {
            sum[i][i] = sourceDigits[i];
            count[sum[i][i]]++;
        }


        for (int i = 0; i < length - 1; i++) {
            for (int j = i + 1; j < length; j++) {
                sum[i][j] = sum[i][j - 1] + sourceDigits[j];
                count[sum[i][j]]++;
            }
        }

        long answ = 0;

        if (a != 0) {
            for (int i = 1; i <= sumOfLength; i++) {
                if (count[i] == 0 || a % i != 0 || a / i > sumOfLength) continue;
                answ += 1L * count[i] * count[((int) (a / i))];
            }
        } else {
            for (int i = 1; i <= sumOfLength; i++) {
                answ += count[i];
            }
            answ *= count[0] * 2L;
            answ += 1L * count[0] * count[0];
        }
        out.print(answ);

    }

    public void close() {
        out.flush();
        out.close();
    }
}
