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
/*
    Date         :
    Problem Name :
    Location     :
    Algorithm    :
    Status       :
    CodingTime   :
    ReadingTime  :
*/

import java.util.*;
import java.io.*;
public class Main {
    static BufferedReader reader 
		= new BufferedReader(new InputStreamReader(System.in));       

    public static void main(String[] args){
        int a = nextInt();
        char[] inp = nextLine().toCharArray();
        int len = inp.length;
        int[] s = new int[len];
        for (int i = 0; i < len; i++) s[i] = inp[i] - '0';
        long[] cnt = new long[36005]; // cnt[i] = the number of partial sums (= i) of s 
        for (int from = 0; from < len; from ++){
            int tmp = s[from];
            cnt[tmp] ++;
            for (int to = from + 1; to < len; to ++){
                tmp += s[to];
                cnt[tmp] ++;
            }
        }
        long acc = 0; // counting the number of possibilities
        if (a == 0){
            acc = cnt[0] * cnt[0];
            for (int i = 1; i < cnt.length; i++){
                acc += 2 * cnt[i] * cnt[0];
            }
        } else {
            for (int i = 1 + a/36000; i * i <= a; i++){
                if (a % i == 0){
                    if (i * i == a){
                        acc += cnt[i] * cnt[i];
                    } else {
                        acc += 2 * cnt[i] * cnt[a / i];
                    }
                }
            }
        }
        System.out.println(acc);
    }

    static int nextLong(){
        return Integer.parseInt(nextLine());
    }
    static int nextInt(){
        return Integer.parseInt(nextLine());
    }
    static long[] nextLongArrayFrom1(){
        String[] inp = nextLine().split("\\s+");
        long[] ary = new long[inp.length + 1];
        for (int i = 0; i < inp.length; i++){
            ary[i+1] = Long.parseLong(inp[i]);
        }
        return ary;
    }
    static long[] nextLongArray(){
        String[] inp = nextLine().split("\\s+");
        long[] ary = new long[inp.length];
        for (int i = 0; i < inp.length; i++){
            ary[i] = Long.parseLong(inp[i]);
        }
        return ary;
    }
    static int[] nextIntArrayFrom1(){
        String[] inp = nextLine().split("\\s+");
        int[] ary = new int[inp.length + 1];
        for (int i = 0; i < inp.length; i++){
            ary[i+1] = Integer.parseInt(inp[i]);
        }
        return ary;
    }
    static int[] nextIntArray(){
        String[] inp = nextLine().split("\\s+");
        int[] ary = new int[inp.length]; for (int i = 0; i < ary.length; i++){
            ary[i] = Integer.parseInt(inp[i]);
        }
        return ary;
    }
	static String nextLine(){
		try { 
			return reader.readLine().trim();
		} catch (Exception e){}
		return null;
	}
}

