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


import static java.lang.Math.*;

    public class solver {
    
 
    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
    
    BufferedReader in;
    static PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");
    
    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){          
             in = new BufferedReader(new InputStreamReader(System.in));
             out = new PrintWriter(System.out);            
        }else{  
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");           
        }
    }
    
    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){               
                return null;
            }
        }
        return tok.nextToken();
    }
    
    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }
    
    long readLong() throws IOException{
        return Long.parseLong(readString());
    }
    
    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }
    
    public static void main(String[] args) throws IOException, ParseException{       
        new solver().run();
    }
    
    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }
    int[] iMas(int n) throws IOException{
        int[] a=new int[n];
        for (int i=0;i<n;i++){
            a[i]=readInt();
        }
        return a;
    }
    void oMas(int[] a){
        for (int i=0;i<a.length;i++){
            out.println(a[i]);
        }
    }
    
    
    public void solve() throws IOException, ParseException{         
        int k=readInt();
        long[] a=new long[40000];
        char[] x=readString().toCharArray();
        int n=x.length;
        int k0=0;
        if (x[0]=='0') k0++;
        int[] pref=new int[n];
        pref[0]=x[0]-'0';
        for (int i=1;i<n;i++){
            if (x[i]=='0') k0++;
            pref[i]=pref[i-1]+(x[i]-'0');
        }
        
        
    
        for (int i=0;i<n;i++){
            for (int j=0;j<=i;j++){
                int sum=pref[i];
                if (j>0) sum-=pref[j-1];
                a[sum]++;
            }
        }
        
        long all=0;
        for (int i=0;i<a.length;i++){
            all+=(long)a[i];
        }
        //out.println("a"+all);
        
        long answer=0;
        
        if (k==0){
            
            long kol0=a[0];
            answer=(long)kol0*(all-n)*2;
            answer+=(long)kol0*2*n-(long)kol0*kol0;
            out.println(answer);
            return;
        }
        
        
        
        for (int i=1;i<a.length;i++){
            if (a[i]==0) continue;
            
            if (k%i==0){
                int l=k/i;
                if (l<40000) answer+=(long)a[i]*a[l];               
            }           
        }
        out.println(answer);
        
    }
    
    
    
    public void run() throws IOException, ParseException{
        init();        
        solve();        
        out.close();
    }
    
    
}