#include<bits/stdc++.h>
using namespace std;
string S;
int p,num[8],length,ans;
bool judge(int a,int b)
{
int tmp=0;
for(int i=a;i<=b;i++)
tmp=tmp*10+num[i];
return tmp%p==0;
}
int main()
{
cin>>p>>S;
length=S.size();
for(int i=0;i<length;i++)
num[i+1]=S[i]-'0';
for(int i=1;i<=length;i++)
for(int j=i;j<=length;j++)
if(judge(i,j))
ans++;
cout<<ans;
return 0;
}
开o2=RE,不开WA