#include <cstdio>
#define MaxN (1<<21)
#define c(i, j) ((i)*b+(j))
unsigned n, nr, a, b, t[MaxN], cd[MaxN];
char ok[MaxN], cif[MaxN];
void test(unsigned r1, unsigned r2, unsigned T, unsigned c){
int cod = c(r1, r2);
if (!ok[cod]){
t[cod] = T;
cif[cod] = c;
ok[cod] = 1;
cd[nr++] = c(r1, r2);
}
}
void expand(unsigned x, unsigned y){
unsigned r1=(10*x)%a, r2=(10*y)%b;
test(r1, r2, c(x, y), 0);
r1++, r2++;
if (r1>=a) r1-=a;
if (r2>=b) r2-=b;
test(r1, r2, c(x, y), 1);
}
void refa(unsigned c){
if (c!=c(1, 1)) refa(t[c]);
printf("%d", cif[c]);
}
int main()
{
freopen("multiplu.in", "r", stdin);
freopen("multiplu.out", "w", stdout);
scanf("%d %d", &a, &b);
cd[nr++] = c(1,1);
ok[c(1,1)]=0;
cif[c(1,1)]=1;
unsigned j=0;
while (!ok[0]){
expand(cd[j]/b, cd[j]%b);
j++;
}
refa(0);
}