using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Zadatak1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int x, y;
            x = Convert.ToInt32(Console.ReadLine());
            y = Convert.ToInt32(Console.ReadLine());
//broj karaktera
            string x1 = x.ToString();
            int nofcx = x1.Length;
            string y1 = y.ToString();
            int nofcy = y1.Length;
//promenljive
            int j = 0;
            int d = 0;
            int s = 0;
            int h = 0;
            int h2 = 0;
            int h3 = 0;
            int m = 0;
            int m2 = 0;
            int m3 = 0;
            long mil = 0;
            int j1 = 0;
            int d1 = 0;
            int s1 = 0;
            int h1 = 0;
            int h21 = 0;
            int h31 = 0;
            int m1 = 0;
            int m21 = 0;
            int m31 = 0;
            long mil1 = 0;
//cifre za prvi broj
            if (nofcx > 0)
                j = x % 10;
            if (nofcx > 1) 
                d = x % 100 / 10;
            if (nofcx > 2)
                s = x % 1000 / 100;
            if (nofcx > 3)
                h = x % 10000 / 1000;
            if (nofcx > 4)
                h2 = x % 100000 / 10000;
            if (nofcx > 5)
                h3 = x % 1000000 / 100000;
            if (nofcx > 6)
                m = x % 10000000 / 1000000;
            if (nofcx > 7)
                m2 = x % 100000000 / 10000000;
            if (nofcx > 8)
                m3 = x % 1000000000 / 100000000;
            if (nofcx > 9)
                mil = x % 10000000000 / 1000000000;
//cifre za drugi broj
            if (nofcy > 0)
                j1 = y % 10;
            if (nofcy > 1)
                d1 = y % 100 / 10;
            if (nofcy > 2)
                s1 = y % 1000 / 100;
            if (nofcy > 3)
                h1 = y % 10000 / 1000;
            if (nofcy > 4)
                h21 = y % 100000 / 10000;
            if (nofcy > 5)
                h31 = y % 1000000 / 100000;
            if (nofcy > 6)
                m1 = y % 10000000 / 1000000;
            if (nofcy > 7)
                m21 = y % 100000000 / 10000000;
            if (nofcy > 8)
                m31 = y % 1000000000 / 100000000;
            if (nofcy > 9)
                mil1 = y % 10000000000 / 1000000000;
//uporedjivaje vece manje
            int jk = 0;
            int dk = 0;
            int sk = 0;
            int hk = 0;
            int h2k = 0;
            int h3k = 0;
            int mk = 0;
            int m2k = 0;
            int m3k = 0; 
            long milko = 0;
            if (j > j1)
                jk = j;
            if (j < j1)
                jk = j1;
            if (d > d1)
                dk = d;
            if (d < d1)
                dk = d1;
            if (s > s1)
                sk = s;
            if (s < s1)
                sk = s1;
            if (h > h1)
                hk = h;
            if (h < h1)
                hk = h1;
            if (h2 > h21)
                h2k = h2;
            if (h2 < h21)
                h2k = h21;
            if (h3 > h31)
                h3k = h3;
            if (h3 < j1)
                h3k = h31;
            if (m > m1)
                mk = m;
            if (m < m1)
                mk = m1;
            if (m2 > m21)
                m2k = m2;
            if (m2 < m21)
                m2k = m21;
            if (m3 > m31)
                m3k = m3;
            if (m3 < m31)
                m3k = m31;
            if (mil > mil1)
                milko = mil;
            if (mil < mil1)
                milko = mil1;
            Console.WriteLine(milko * 1000000000 + m3k * 100000000 + m2k * 10000000 + mk * 1000000 + h3k * 100000 + h2k * 10000 + hk * 1000 + sk * 100 + dk * 10 + jk);
        }
    }
}