#include<stdio.h>
#include<cstdio>
#include<math.h>
int main()
{
    int V,brN=0,X,d,k;
scanf("%d",&V);
scanf("%d",&d);
scanf("%d",&k);
if((d==1)||(d==2)||(d==5)) X=d*pow(10,k);
else printf("Pogresno uneto d!");
while(V%X==1)
brN++;
printf("%d",brN);

return 0;

}