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.FileNotFoundException;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.AbstractMap;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 * 
 * @author cs6096
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        BR in = new BR(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA {
    public void solve(int testNumber, BR in, PrintWriter out) {
        int a1 = in.ni();
        char[] dig = in.next().toCharArray();
        int[] l1 = new int[dig.length];
        int n1 = l1.length;
        for (int i = 0; i < n1; i++) {
            l1[i] = dig[i] - '0';
        }
        
        int[] sum = new int[n1+1];
        int temp1 = 0;
        for (int i=0;i < n1; i++){
            temp1 += l1[i];
            sum[i+1] = temp1;
        }
        IntL vals = new IntL(4000*4000);
        int zero = 0;
        for (int i = 1;i < n1 +1; i++){
            for (int j =0; j < i; j++){
                int cur = sum[i] - sum[j];
                vals.add(cur);
                if (cur == 0) zero++;
            }
        }
        int[] factors = NT.factor2(a1);
        if (a1 == 0) factors = new int[] {0};
        CS count = new CS();
        for (int e: vals){
            if (Arrays.binarySearch(factors, e)>=0){
                count.add(e);
            }
        }
        BigInteger fin = BigInteger.ZERO;
        for (int j = 0; j < factors.length; j++) {
            int cur = factors[j];
            long q1 = count.get(cur);
            if (cur == 0) {
                long q2 = n1 * (n1 + 1) / 2;
                long curno = q1 * q2;
                fin = fin.add(BigInteger.valueOf(curno));
            }
            else {
                int need = a1 / cur;
                long q2 = count.get(need);
                long curno = q1 * q2;
                fin = fin.add(BigInteger.valueOf(curno));
            }
        }
        if (a1 == 0){
            int zeros = count.get(0);
            long temp2 = n1 *(n1 +1)/2;
            long nonzeros = temp2 - zeros;
            fin = fin.add(BigInteger.valueOf(nonzeros*zeros));
        }

        out.println(fin);

    }

    static void px(Object... objects) {
        System.out.println(Arrays.toString(objects));
    }

    static class CS {
        TreeMap<Integer, Integer> m1 = new TreeMap();

        void add(int n1) {
            add(n1, 1);
        }

        void add(int n1, int count) {
            int old = 0;
            if (m1.containsKey(n1)) old = m1.get(n1);
            m1.put(n1, count + old);
        }

        int get(int n1) {
            if (m1.containsKey(n1)) return m1.get(n1);
            return 0;
        }

        public String toString() {
            return m1.toString();
        }
    }

}

class BR {
    BufferedReader k1 = null;
    StringTokenizer k2 = null;

    public BR(InputStream in) {
        k1 = new BufferedReader(new InputStreamReader(in));
    }

    public BR(String f1) {
        try {
            k1 = new BufferedReader(new FileReader(f1));
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public String next() {
        for (;;) {
            if (k2 == null || !k2.hasMoreTokens()) {
                String temp = null;
                try {
                    temp = k1.readLine();
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
                if (temp == null) return null;
                k2 = new StringTokenizer(temp);
            }
            else break;
        }

        return k2.nextToken();
    }

    public int ni() {
        return Integer.parseInt(next());
    }

}

class NT {

    public static int[] factor2(int n1) {
        IntL l1 = new IntL();
        IntL l2 = new IntL();
        for (int i = 1; i * i <= n1; i++) {
            if (n1 % i == 0) {
                l1.add(i);
                if (i != n1 / i) l2.add(n1 / i);
            }

        }
        int[] fin = new int[l1.size + l2.size];
        for (int i = 0; i < l1.size; i++) {
            fin[i] = l1.get(i);
        }
        for (int i = l1.size; i < l1.size + l2.size; i++) {
            fin[i] = l2.get(l2.size - 1 - (i - l1.size));
        }
        return fin;
    }

}

class IntL implements Iterable<Integer> {
    public int[] l1 = null;
    public int size = 0;

    public IntL(int initialCapacity) {
        this.l1 = new int[initialCapacity];
    }

    public IntL() {
        this(5);
    }

    public void add(int e) {
        if (size == l1.length) {
            l1 = Arrays.copyOf(l1, ((l1.length * 3) >> 1) + 1);
        }
        l1[size++] = e;
    }

    public int get(int id) {
        if (id >= 0) return l1[id];
        else return l1[size + id];
    }

    public String toString() {
        StringBuilder fin = new StringBuilder();
        fin.append('{');
        for (int i = 0; i < size; i++) {
            if (i != 0) fin.append(", ");
            fin.append(l1[i]);
        }
        fin.append('}');
        return fin.toString();
    }

    public Iterator<Integer> iterator() {
        return new It();
    }

    public class It implements Iterator<Integer> {
        int ptr = 0;

        public boolean hasNext() {
            if (ptr < size) return true;
            return false;
        }

        public Integer next() {
            int fin = l1[ptr];
            ptr++;
            return fin;
        }

        public void remove() {}
    }
}