using System;

namespace Takmicenje
{
    class Program
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());
            long y = long.Parse(Console.ReadLine());
            long z = 0, m = Math.Max(x, y), n = Math.Min(x, y);
            int k = 1;
            while (m != 0)
            {
                long max = m % 10;
                if (n % 10 > max)
                {
                    max = n % 10;
                }
                else if (n % 10 == max && n != 0)
                {
                    z += k * max;
                    k *= 10;
                }
                z += max * k;
                k *= 10;
                m /= 10;
                n /= 10;
            }
            Console.WriteLine(z);
        }
    }
}