n=int(input())
c=str(n)
m=int(input())
s=[]
count=0

for i in range(len(c)-3):
    s.append(c[i:i+4])

for i in range(len(c)-4):
    s.append(c[i:i+5])
print(s)
for i in s:
    if(int(i)%m==0):
        count+=1
print(count)   