using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int j, d, s, h, dh, nbr;
            int x = Convert.ToInt32(Console.ReadLine());
            int y = Convert.ToInt32(Console.ReadLine());
            int dh1 = x / 10000;
            int h1 = x % 10000 / 1000;
            int s1 = x % 1000 / 100;
            int d1 = x % 100 / 10;
            int j1 = x % 10;
            int dh2 = y / 10000;
            int h2 = y % 10000 / 1000;
            int s2 = y % 1000 / 100;
            int d2 = y % 100 / 10;
            int j2 = y % 10;
            if (j1 > j2)
                j = j1;
            else if (j1 == j2)
                j = j1 + j2 * 10;
            else
                j = j2;
            if (d1 > d2)
                d = d1;
            else if (d1 == d2)
                d = d1 + d2 * 10;
            else
                d = d2;
            if (s1 > s2)
                s = s1;
            else if (s1 == s2)
                s = s1 + s2 * 10;
            else
                s = s2;
            if (h1 > h2)
                h = h1;
            else if (h1 == h2)
                h = h1 + h2 * 10;
            else
                h = h2;
            if (dh1 > dh2)
                dh = dh1;
            else if (dh1 == dh2)
                dh = dh1 + dh2 * 10;
            else
                dh = dh2;
            if (j1 == j2 && d1 == d2 && h1 == h2)
                nbr = dh * 10000000 + h * 100000 + s * 10000 + d * 100 + j;
            else if (d1 == d2 && d1 != 0 && d2 != 0)
                nbr = dh * 100000 + h * 10000 + s * 1000 + d * 10 + j;
            else
                nbr = dh * 10000 + h * 1000 + s * 100 + d * 10 + j;
            Console.WriteLine("novi broj je " + nbr);

        }
    }
}