long a,b;n;main(i){for(scanf("%ld%ld",&a,&b);a%10<1;a/=10);for(;n=a/b%10,++i<99?a=a%b*10:0;);n=!printf("%d",a?-1:n);}