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

public class Matrix {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        
        int A = sc.nextInt();
        String S = sc.next();
        
        int N = S.length();
        
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
        	arr[i] = S.charAt(i) - '0';
        }
        
        int[] sums = new int[N + 1];
        for (int i = 1; i <= N; i++) {
        	sums[i] = sums[i - 1] + arr[i - 1];
        }
        
        int[] freq = new int[40000];
        for (int i = 0; i < N; i++) {
        	for (int j = i; j < N; j++) {
        		int part = sums[j + 1] - sums[i];
        		freq[part]++;
        	}
        }
        
        if (A == 0) {
        	long zeros = (long)freq[0] * freq[0];
        	for (int i = 1; i < freq.length; i++) {
        		zeros += (2L * freq[0] * freq[i]);
        	}
        	System.out.println(zeros);
        	return;
        }
        
        long cnt = 0;
        for (int i = 1; i < freq.length; i++) {
        	if (A % i == 0 && A / i < freq.length) {
        		cnt += ((long)freq[i] * freq[A / i]); 
        	}
        }
        System.out.println(cnt);
    }

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        
        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; i++) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }
}