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.*;
import java.util.*;

public class Main implements Runnable {

	public void _main() throws IOException {
		int a = nextInt();
		char[] s = next().toCharArray();
		int[] sum = new int[s.length];
		sum[0] = s[0] - '0';
		for (int i = 1; i < s.length; i++) {
			sum[i] = sum[i - 1] + s[i] - '0';			
		}
		int[] cnt = new int[10 * s.length + 100];
		for (int i = 0; i < s.length; i++) {
			for (int j = i; j < s.length; j++) {
				++cnt[sum[j] - (i == 0 ? 0 : sum[i - 1])];
			}
		}
		long res = 0;
		if (a == 0) {
			long any = 0;
			for (int i = 1; i < cnt.length; i++) {
				any += cnt[i];
			}
			res = 2 * any * cnt[0] + cnt[0] * (long)cnt[0];
		} else {
			for (int d = 1; d*d <= a; d++) {
				if (a % d == 0) {
					if (d >= cnt.length || a/d >= cnt.length) continue;
					long cur = cnt[d] * (long)cnt[a / d];
					if (d*d < a) {
						cur *= 2;
					}
					res += cur;
				}
			}
		}
		out.println(res);
	}


	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

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

	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

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

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

	public static void main(String[] args) {
		Locale.setDefault(Locale.UK);
		new Thread(new Main()).start();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			//in = new BufferedReader(new FileReader("a.in"));
			//out = new PrintWriter(new FileWriter("a.out"));

			_main();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(202);
		}
	}

}
