#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) ((v).begin()), ((v).end())
void BRO(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
template <typename T> void stop(T x){return void(cout << x << endl);}
void HIRO(void) {
#ifndef ONLINE_JUDGE
freopen("D:\\Personal\\No\\CP\\input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
}
const long long mod = 1e9 + 7;
const int MOD = 998244353;
/*
When I wrote this, only Allah and I understood what I was doing
Now, only Allah knows
*/
int dp[20][2][2][2];
void get_this_shit_done() {
string a , b;
cin >> a >> b;
if(a.size() < b.size()){
std::reverse(a.begin(), a.end());
while(a.size() < b.size()) a.push_back('0');
std::reverse(a.begin(), a.end());
}
// dp[idx][low][high][started]
memset(dp, -1, sizeof dp);
function<int(int, bool, bool, bool)> go = [&](int idx, bool low, bool high, bool started)-> int {
if(idx == a.size()){
return 1;
}
int &ret = dp[idx][low][high][started];
if(~ret)
return ret;
ret = 0;
int mn = low ? a[idx] - '0' : 0;
int mx = high ? b[idx] - '0' : 9;
if(not started){
for(int i = mn ; i <= mx ; i++){
if(i != 0)
ret = max(ret, go(idx + 1, low & (i == mn), high & ( i == mx ), true) * i);
else
ret = go(idx + 1, low & (i == mn), high & (i == mx), false);
}
}else{
for (int i = mn; i <= mx ; ++i) {
ret = max(ret, go(idx + 1, low & (i == mn), high & ( i == mx ), started) * i);
}
}
return ret;
};
int res = go(0, true, true, false);
vector<int>v;
function<void(int, bool, bool, bool)> build = [&](int idx, bool low, bool high, bool started) -> void {
if(idx == b.size()) return;
int ret = go(idx, low, high, started);
int mn = low ? a[idx] - '0' : 0;
int mx = high ? b[idx] - '0' : 9;
if(not started){
for(int i = mn ; i <= mx ; i++){
if(i != 0){
if(ret == go(idx + 1, low & (i == mn), high & (i == mx), true) * i){
cout << i;
build(idx + 1, low & (i == mn), high & (i == mx), true);
}
} else {
if(ret == go(idx + 1, low & (i == mn), high & (i == mx), false)) {
build(idx + 1, low & (i == mn), high & (i == mx), false);
}
}
}
} else {
for (int i = mn; i <= mx ; ++i) {
if(ret == go(idx + 1, low & (i == mn), high & (i == mx), started) * i) {
cout << i;
build(idx + 1, low & (i == mn), high & (i == mx), started);
}
}
}
};
build(0, true, true, false);
}
signed main() {
BRO();
HIRO();
//freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int t = 1 ;
//cin >> t;
while(t--){
get_this_shit_done();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGFsbCh2KSAoKHYpLmJlZ2luKCkpLCAoKHYpLmVuZCgpKQoKdm9pZCBCUk8odm9pZCkgewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKE5VTEwpOwogICAgY291dC50aWUoTlVMTCk7Cn0KdGVtcGxhdGUgPHR5cGVuYW1lIFQ+IHZvaWQgc3RvcChUIHgpe3JldHVybiB2b2lkKGNvdXQgPDwgeCA8PCBlbmRsKTt9CnZvaWQgSElSTyh2b2lkKSB7CiNpZm5kZWYgT05MSU5FX0pVREdFCiAgICBmcmVvcGVuKCJEOlxcUGVyc29uYWxcXE5vXFxDUFxcaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICAvLyAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKCiNlbmRpZgp9CmNvbnN0IGxvbmcgbG9uZyBtb2QgPSAxZTkgKyA3Owpjb25zdCBpbnQgTU9EID0gOTk4MjQ0MzUzOwovKgogIFdoZW4gSSB3cm90ZSB0aGlzLCBvbmx5IEFsbGFoIGFuZCBJIHVuZGVyc3Rvb2Qgd2hhdCBJIHdhcyBkb2luZwogIE5vdywgb25seSBBbGxhaCBrbm93cwogICovCgppbnQgZHBbMjBdWzJdWzJdWzJdOwp2b2lkIGdldF90aGlzX3NoaXRfZG9uZSgpIHsKICAgIHN0cmluZyBhICwgYjsKICAgIGNpbiA+PiBhID4+IGI7CiAgICBpZihhLnNpemUoKSA8IGIuc2l6ZSgpKXsKICAgICAgICBzdGQ6OnJldmVyc2UoYS5iZWdpbigpLCBhLmVuZCgpKTsKICAgICAgICB3aGlsZShhLnNpemUoKSA8IGIuc2l6ZSgpKSBhLnB1c2hfYmFjaygnMCcpOwogICAgICAgIHN0ZDo6cmV2ZXJzZShhLmJlZ2luKCksIGEuZW5kKCkpOwogICAgfQogICAgLy8gZHBbaWR4XVtsb3ddW2hpZ2hdW3N0YXJ0ZWRdCiAgICBtZW1zZXQoZHAsIC0xLCBzaXplb2YgZHApOwogICAgZnVuY3Rpb248aW50KGludCwgYm9vbCwgYm9vbCwgYm9vbCk+IGdvID0gWyZdKGludCBpZHgsIGJvb2wgbG93LCBib29sIGhpZ2gsIGJvb2wgc3RhcnRlZCktPiBpbnQgewogICAgICAgIGlmKGlkeCA9PSBhLnNpemUoKSl7CiAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgIH0KICAgICAgICBpbnQgJnJldCA9IGRwW2lkeF1bbG93XVtoaWdoXVtzdGFydGVkXTsKICAgICAgICBpZih+cmV0KQogICAgICAgICAgICByZXR1cm4gcmV0OwogICAgICAgIHJldCA9IDA7CiAgICAgICAgaW50IG1uID0gbG93ID8gYVtpZHhdIC0gJzAnIDogMDsKICAgICAgICBpbnQgbXggPSBoaWdoID8gYltpZHhdIC0gJzAnIDogOTsKICAgICAgICBpZihub3Qgc3RhcnRlZCl7CiAgICAgICAgICAgIGZvcihpbnQgaSA9IG1uIDsgaSA8PSBteCA7IGkrKyl7CiAgICAgICAgICAgICAgICBpZihpICE9IDApCiAgICAgICAgICAgICAgICAgICAgcmV0ID0gbWF4KHJldCwgZ28oaWR4ICsgMSwgbG93ICYgKGkgPT0gbW4pLCBoaWdoICYgKCBpID09IG14ICksIHRydWUpICogaSk7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgcmV0ID0gZ28oaWR4ICsgMSwgbG93ICYgKGkgPT0gbW4pLCBoaWdoICYgKGkgPT0gbXgpLCBmYWxzZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9ZWxzZXsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IG1uOyBpIDw9IG14IDsgKytpKSB7CiAgICAgICAgICAgICAgICByZXQgPSBtYXgocmV0LCBnbyhpZHggKyAxLCBsb3cgJiAoaSA9PSBtbiksIGhpZ2ggJiAoIGkgPT0gbXggKSwgc3RhcnRlZCkgKiBpKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgfTsKICAgIGludCByZXMgPSBnbygwLCB0cnVlLCB0cnVlLCBmYWxzZSk7CiAgICB2ZWN0b3I8aW50PnY7CiAgICBmdW5jdGlvbjx2b2lkKGludCwgYm9vbCwgYm9vbCwgYm9vbCk+IGJ1aWxkID0gWyZdKGludCBpZHgsIGJvb2wgbG93LCBib29sIGhpZ2gsIGJvb2wgc3RhcnRlZCkgLT4gdm9pZCB7CiAgICAgICAgaWYoaWR4ID09IGIuc2l6ZSgpKSByZXR1cm47CiAgICAgICAgaW50IHJldCA9IGdvKGlkeCwgbG93LCBoaWdoLCBzdGFydGVkKTsKICAgICAgICBpbnQgbW4gPSBsb3cgPyBhW2lkeF0gLSAnMCcgOiAwOwogICAgICAgIGludCBteCA9IGhpZ2ggPyBiW2lkeF0gLSAnMCcgOiA5OwogICAgICAgIGlmKG5vdCBzdGFydGVkKXsKICAgICAgICAgICAgZm9yKGludCBpID0gbW4gOyBpIDw9IG14IDsgaSsrKXsKICAgICAgICAgICAgICAgIGlmKGkgIT0gMCl7CiAgICAgICAgICAgICAgICAgICAgaWYocmV0ID09IGdvKGlkeCArIDEsIGxvdyAmIChpID09IG1uKSwgaGlnaCAmIChpID09IG14KSwgdHJ1ZSkgKiBpKXsKICAgICAgICAgICAgICAgICAgICAgICAgY291dCA8PCBpOwogICAgICAgICAgICAgICAgICAgICAgICBidWlsZChpZHggKyAxLCBsb3cgJiAoaSA9PSBtbiksIGhpZ2ggJiAoaSA9PSBteCksIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGlmKHJldCA9PSBnbyhpZHggKyAxLCBsb3cgJiAoaSA9PSBtbiksIGhpZ2ggJiAoaSA9PSBteCksIGZhbHNlKSkgewogICAgICAgICAgICAgICAgICAgICAgICBidWlsZChpZHggKyAxLCBsb3cgJiAoaSA9PSBtbiksIGhpZ2ggJiAoaSA9PSBteCksIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBmb3IgKGludCBpID0gbW47IGkgPD0gbXggOyArK2kpIHsKICAgICAgICAgICAgICAgIGlmKHJldCA9PSBnbyhpZHggKyAxLCBsb3cgJiAoaSA9PSBtbiksIGhpZ2ggJiAoaSA9PSBteCksIHN0YXJ0ZWQpICogaSkgewogICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgaTsKICAgICAgICAgICAgICAgICAgICBidWlsZChpZHggKyAxLCBsb3cgJiAoaSA9PSBtbiksIGhpZ2ggJiAoaSA9PSBteCksIHN0YXJ0ZWQpOwogICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9OwoKICAgIGJ1aWxkKDAsIHRydWUsIHRydWUsIGZhbHNlKTsKfQoKc2lnbmVkIG1haW4oKSB7CiAgICBCUk8oKTsKICAgIEhJUk8oKTsKICAgIC8vZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICAvLyAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKICAgIGludCB0ID0gMSA7CiAgICAvL2NpbiA+PiB0OwogICAgd2hpbGUodC0tKXsKICAgICAgICBnZXRfdGhpc19zaGl0X2RvbmUoKTsKICAgIH0KfQo=