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 static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        try {
            if (new File("input.txt").exists())
                System.setIn(new FileInputStream("input.txt"));
        } catch (SecurityException e) {
        }
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    private void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    private void solve() throws IOException {
        long a = nextLong();
        char[] s = nextToken().toCharArray();
        int n = s.length;
        Map<Long, Long> map = new HashMap<Long, Long>();
        for(int i = 0; i < n; i++){
            long sumIJ = 0;
            for(int j = i; j < n; j++){
                sumIJ += (long)(s[j] - '0');
                if(sumIJ == 0 || a % sumIJ == 0)
                    if(map.containsKey(sumIJ))
                        map.put(sumIJ, map.get(sumIJ) + 1);
                    else 
                        map.put(sumIJ,1L);
            }
        }
        long answer = 0;
        for(int i = 0; i < n; i++){
            long sumIJ = 0;
            for(int j = i; j < n; j++){
                sumIJ += (long)(s[j] - '0');
                if(a != 0 && sumIJ != 0 && a % sumIJ == 0){
                    long need = a / sumIJ;
                    if(map.containsKey( need ))
                        answer += (long)map.get(need);
                } 
            }
        }
        if(a == 0 && map.get(0L) != null)
            answer += (n * (n+1)) * map.get(0L) - map.get(0L) * map.get(0L);
        out.println(answer);
    }

    void chk(boolean b) {
        if (b)
            return;
        System.out.println(new Error().getStackTrace()[1]);
        exit(999);
    }
    void deb(String fmt, Object... args) {
        System.out.printf(Locale.US, fmt + "%n", args);
    }
    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        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());
    }
    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }
    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }
}
