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 sys
from collections import defaultdict as dd
from collections import deque

def eprint(*args):
    print(*args, file=sys.stderr)
pl=1
from math import *
import copy
#sys.setrecursionlimit(10**6)
if pl:
	input=sys.stdin.readline

def li():
	return [int(xxx) for xxx in input().split()]
def fi():
	return int(input())
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())	
 

d=[]		
from bisect import *		

from itertools import permutations 
from bisect import *
f=[0 for i in range(100)]

for i in range(1,100):
	if i==1:
		f[i]=1
	else:
		f[i]=2*f[i-1]+1

#print(f[:15])
def rec(n,k):
	s=[]
	while n!=0:
		n,r=n//k,n%k
		#print(n,r)
		if r<0:
			r-=k
			n+=1
		#print(s,n,r)	
		s.append(r)		
	return s		
n=fi()
s=si()
a=[]
for i in range(len(s)):
	a.append(int(s[i]))
d={}	
nn=len(s)
for i in range(nn):
	c=0
	for j in range(i,nn):
		c+=a[j]
		if c not in d:
			d[c]=1
		else:
			d[c]+=1
ans=0
#print(d)	
if n==0 and 0 in d:
	for j in d:
		if j==0:
			ans+=d[0]*d[0]
		else:	
			ans+=d[j]*d[0]*2

for j in range(1,int(sqrt(n))+1):
	if n%j==0:
		if n//j==j:
			if j in d:
				ans+=(d[j]*(d[j]))
		elif n//j in d and j in d:
			ans+=d[j]*d[n//j]*2

print(ans)