#include <bits/stdc++.h>

using namespace std;

long long brcif (long long a)
{
    long long br = 0;
    while (a > 0)
    {
        a /= 10;
        br++;
    }
    return br;
}

int main()
{
    long long a, b, m;
    cin >> a >> b;
    long long x = 1, y = 1;
    if (brcif(a) > brcif(b))
    {
        for (long long i = 0; i < brcif(b); i++) x *= 10;
        cout << a / x;
        a = a % x;
        long long n = 1;
        m = brcif(b);
        while (m > 0)
        {
            while (n > 0)
            {
                y *= 10;
                n--;
            }
            if (a / (x / y) % 10 > b / (x / y) % 10) cout << a / (x / y) % 10;
            else if (a / (x / y) % 10 == b / (x / y) % 10) cout << a / (x / y) % 10 << b / (x / y) % 10;
            else if (a / (x / y) % 10 < b / (x / y) % 10) cout << b / (x / y) % 10;
            n++;
            m--;
        }
    }
    else if (brcif(a) == brcif(b))
    {
        for (long long i = 0; i < brcif(a); i++) x *= 10;
        long long n = 1;
        m = brcif(a);
        while (m > 0)
        {
            while (n > 0)
            {
                y *= 10;
                n--;
            }
            if (a / (x / y) % 10 > b / (x / y) % 10) cout << a / (x / y) % 10;
            else if (a / (x / y) % 10 == b / (x / y) % 10) cout << a / (x / y) % 10 << b / (x / y) % 10;
            else if (a / (x / y) % 10 < b / (x / y) % 10) cout << b / (x / y) % 10;
            n++;
            m--;
        }
    }
    else if (brcif(a) < brcif(b))
    {
        for (long long i = 0; i < brcif(b); i++) x *= 10;
        cout << b / x;
        b = b % x;
        long long n = 1;
        m = brcif(a);
        while (m > 0)
        {
            while (n > 0)
            {
                y *= 10;
                n--;
            }
            if (a / (x / y) % 10 > b / (x / y) % 10) cout << a / (x / y) % 10;
            else if (a / (x / y) % 10 == b / (x / y) % 10) cout << a / (x / y) % 10 << b / (x / y) % 10;
            else if (a / (x / y) % 10 < b / (x / y) % 10) cout << b / (x / y) % 10;
            n++;
            m--;
        }
    }
    return 0;
}