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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PipedWriter;
import java.io.PrintWriter;

import java.io.BufferedReader;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class C {
    private static BufferedReader in;
    private static StringTokenizer st;
    private static PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        
        in = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer("");
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int a = nextInt();
        String line = in.readLine();
        int n = line.length();
        int s[] = new int[n+1];
        
        for (int i = 1; i <=n; i++) {
            s[i] = line.charAt(i-1) - '0';
        }
        int sum[] = new int[n + 1];
        for (int i = 1; i <=n; i++) {
            sum[i] = sum[i-1] + s[i];
        }
        int all = 0;
        int count[] = new int [(int) 1e6];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < i; j++) {
                count[sum[i] - sum[j]]++;
                all++;
            }
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < i; j++) {
                int x = sum[i] - sum[j];
                if(x > 0){
                    if(a % x == 0){
                        if(a / x < 1e6)
                            ans += count[a / x];
                    }
                }else{
                    if(x == 0 && a == 0){
                        ans += all;
                    }
                }
            }
        }
        out.println(ans);
        out.close();
    }

    private static int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(next());
    }

    private static String next() throws IOException {
        while(!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }
}
