#include <bits/stdc++.h> using namespace std; long long k,m,t,s; bool check(int n) { while(n>0) { int w=n%10; n/=10; if(w>=k) return 0; } return 1; } int main() { cin >> k >> m; while(1) { t++; s=m*t; if(check(s)) { cout << s; return 0; } } }