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.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

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

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int mul = in.nextInt();
        String sequence = in.next();
        int[] sums = new int[sequence.length() + 1];
        for (int i = 0; i < sequence.length(); i++)
            sums[i + 1] = sums[i] + sequence.charAt(i) - '0';
        int[] cnt = new int[sums[sequence.length()] + 1];
        for (int i = 1; i <= sequence.length(); i++)
            for (int j = i; j <= sequence.length(); j++)
                cnt[sums[j] - sums[i - 1]]++;
        long answer = 0;
        if (mul == 0) {
            
            for (int i = 1; i < cnt.length; i++)
                answer += 2L * cnt[0] * cnt[i];
            out.println(answer + 1L * cnt[0] * cnt[0]);
            return;
        }
        for (int div = 1; div <= Math.sqrt(mul + 1); div++)
            if (mul % div == 0) {
                if (div >= cnt.length || mul / div >= cnt.length || div > mul / div)
                    continue;
                answer += 2L * cnt[div] * cnt[mul / div];
                if (div == mul / div)
                    answer -= 1L * cnt[div] * cnt[mul / div];
            }
        out.println(answer);
    }
}

class InputReader {

	private static BufferedReader bufferedReader;
	private static StringTokenizer stringTokenizer;

	public InputReader(InputStream inputStream) {
		bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
		stringTokenizer = null;
	}

	public String next() {
		while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
			try {
				stringTokenizer = new StringTokenizer(bufferedReader.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return stringTokenizer.nextToken();
	}

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

	}

