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

namespace danica
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int x = Convert.ToInt32(Console.ReadLine());
            int y = Convert.ToInt32(Console.ReadLine());
            int jy, dy, sy, hy, dhy, jx, dx, sx, hx, dhx;
            int konacno = 0;
            jy = y % 10;
            dy = (y / 10) % 10;
            sy = (y / 100) % 10;
            hy = (y / 1000) % 10;
            dhy = (y / 10000) % 10;

            jx = x % 10;
            dx = (x / 10) % 10;
            sx = (x / 100) % 10;
            hx = (x / 1000) % 10;
            dhx = (x / 10000) % 10;

            if (jy > jx)
                konacno =  + jy;
            else if (jx > jy)
                konacno = konacno + jx;
            else if(jy == jx)
                konacno = konacno + jx + 10 * jy;

            if (konacno < 10)
            {
                if (dx > dy)
                    konacno = konacno + (dx * 10);
                if (dy > dx)
                    konacno = konacno + (dy * 10);
                if (dx == dy)
                    konacno = konacno + (dx * 100) + (dx * 10);
            }

            else if (konacno > 9)
            {
                if (dx > dy)
                    konacno = konacno + dx * 100;
                if (dy > dx)
                    konacno = konacno + dy * 100;
                if (dx == dy)
                    konacno = konacno + dx * 100 + dx * 1000;
            }
            string asd = Convert.ToString(konacno);
            int asd1 = asd.Length;
            if (asd1 == 2)
            {
                if (sx > sy)
                    konacno += sx * 100;
                if (sy > sx)
                    konacno += sy * 100;
                if (sy == sx)
                    konacno += sy * 100 + sx * 1000;

            }
            if (asd1 == 3)
            {
                if (sx > sy)
                    konacno += sx * 1000;
                if (sy > sx)
                    konacno += sy * 1000;
                if (sy == sx)
                    konacno += sy * 1000 + sx * 10000;
            }
            if (asd1 == 4)
            {
                if (sx > sy)
                    konacno += sx * 10000;
                if (sy > sx)
                    konacno += sy * 10000;
                if (sy == sx)
                    konacno += sy * 10000 + sx * 100000;
            }
            string brojac = Convert.ToString(konacno);
            int broj = brojac.Length;
            if (broj == 3)
            {
                if (hx > hy)
                    konacno += hx * 1000;
                if (hx < hy)
                    konacno += hy * 1000;
                if (hx == hy)
                    konacno += hx * 1000 + hy * 10000;

            }
            if (broj == 4)
            {
                if (hx > hy)
                    konacno += hx * 10000;
                if (hx < hy)
                    konacno += hy * 10000;
                if (hx == hy)
                    konacno += hx * 10000 + hy * 100000;
            }
            if (broj == 5)
            {
                if (hx > hy)
                    konacno += hx * 100000;
                if (hx < hy)
                    konacno += hy * 100000;
                if (hx == hy)
                    konacno += hx * 100000 + hy * 1000000;

            }
            if (broj == 6)
            {
                if (hx > hy)
                    konacno += hx * 1000000;
                if (hx < hy)
                    konacno += hy * 1000000;
                if (hx == hy)
                    konacno += hx * 1000000 + hy * 10000000;
            }
            string brojac2 = Convert.ToString(konacno);
            int broj2 = brojac2.Length;

            if (broj2 == 4)
            {
                if (dhx > dhy)
                    konacno += dhx * 10000;
                if (dhy > dhx)
                    konacno += dhy * 10000;
                if (dhx == dhy)
                    konacno += dhy * 10000 + dhx * 100000;
            }
            if (broj2 == 5)
            {
                if (dhx > dhy)
                    konacno += dhx * 100000;
                if (dhy > dhx)
                    konacno += dhy * 100000;
                if (dhx == dhy)
                    konacno += dhy * 100000 + dhx * 1000000;
            }
            if (broj2 == 6)
            {
                if (dhx > dhy)
                    konacno += dhx * 1000000;
                if (dhy > dhx)
                    konacno += dhy * 1000000;
                if (dhx == dhy)
                    konacno += dhy * 1000000 + dhx * 10000000;
            }
            if (broj2 == 7)
            {
                if (dhx > dhy)
                    konacno += dhx * 10000000;
                if (dhy > dhx)
                    konacno += dhy * 10000000;
                if (dhx == dhy)
                    konacno += dhy * 10000000 + dhx * 100000000;
            }
            if (broj2 == 8)
            {
                if (dhx > dhy)
                    konacno += dhx * 100000000;
                if (dhy > dhx)
                    konacno += dhy * 100000000;
                if (dhx == dhy)
                    konacno += dhy * 100000000 + dhx * 1000000000;
            }

            int ax, ay, bx, by, cx, cy, nx, ny, fx, fy;
            ax = (x / 100000) % 10;
            bx = (x / 1000000) % 10;
            cx = (x / 10000000) % 10;
            nx = (x / 100000000) % 10;
            fx = (x / 1000000000) % 10;

            ay = (y / 100000) % 10;
            by = (y / 1000000) % 10;
            cy = (y / 10000000) % 10;
            ny = (y / 100000000) % 10;
            fy = (y / 1000000000) % 10;
            string brojac3 = Convert.ToString(konacno);
            int broj3 = brojac3.Length;
            if (broj3 == 5) 
            {
                if (ax > ay)
                    konacno += ax * 100000;
                if (ay > ax)
                    konacno += ay * 100000;
                if (ax == ay)
                    konacno += ax * 100000 + ax * 1000000;
            }
            if (broj3 == 6)
            {
                if (ax > ay)
                    konacno += ax * 1000000;
                if (ay > ax)
                    konacno += ay * 1000000;
                if (ax == ay)
                    konacno += ax * 1000000 + ax * 10000000;
            }
            if (broj3 == 7) 
            {
                if (ax > ay)
                    konacno += ax * 10000000;
                if (ay > ax)
                    konacno += ay * 10000000;
                if (ax == ay)
                    konacno += ax * 10000000 + ax * 100000000;
            }
            if (broj3 == 8)
            {
                if (ax > ay)
                    konacno += ax * 100000000;
                if (ay > ax)
                    konacno += ay * 100000000;
                if (ax == ay)
                    konacno += ax * 100000000 + ax * 1000000000;
            }
            if (broj3 == 9)
            {
                if (ax > ay)
                    konacno += ax * 1000000000;
                if (ay > ax)
                    konacno += ay * 1000000000;
                if (ax == ay)
                    konacno += ax * 1000000000 + (ax * 1000000000)*10;
            }


            if (broj3 == 5)
            {
                if (bx > by)
                    konacno += bx * 100000;
                if (by > bx)
                    konacno += by * 100000;
                if (bx == by)
                    konacno += bx * 100000 + bx * 1000000;
            }
            if (broj3 == 6)
            {
                if (bx > by)
                    konacno += bx * 1000000;
                if (by > bx)
                    konacno += by * 1000000;
                if (bx == by)
                    konacno += bx * 1000000 + bx * 10000000;
            }
            if (broj3 == 7)
            {
                if (bx > by)
                    konacno += bx * 10000000;
                if (by > bx)
                    konacno += by * 10000000;
                if (bx == by)
                    konacno += bx * 10000000 + bx * 100000000;
            }
            if (broj3 == 8)
            {
                if (bx > by)
                    konacno += bx * 100000000;
                if (by > bx)
                    konacno += by * 100000000;
                if (bx == by)
                    konacno += bx * 100000000 + bx * 1000000000;
            }
            if (broj3 == 9)
            {
                if (bx > by)
                    konacno += bx * 1000000000;
                if (by > bx)
                    konacno += by * 1000000000;
                if (bx == by)
                    konacno += bx * 1000000000 + (bx * 1000000000) * 10;
            }


            if (broj3 == 5)
            {
                if (cx > cy)
                    konacno += cx * 100000;
                if (cy > cx)
                    konacno += cy * 100000;
                if (cx == cy)
                    konacno += cx * 100000 + cx * 1000000;
            }
            if (broj3 == 6)
            {
                if (cx > cy)
                    konacno += cx * 1000000;
                if (cy > cx)
                    konacno += cy * 1000000;
                if (cx == cy)
                    konacno += cx * 1000000 + cx * 10000000;
            }
            if (broj3 == 7)
            {
                if (cx > cy)
                    konacno += cx * 10000000;
                if (cy > cx)
                    konacno += ay * 10000000;
                if (cx == cy)
                    konacno += cx * 10000000 + cx * 100000000;
            }
            if (broj3 == 8)
            {
                if (cx > ay)
                    konacno += cx * 100000000;
                if (cy > cx)
                    konacno += cy * 100000000;
                if (cx == cy)
                    konacno += cx * 100000000 + cx * 1000000000;
            }
            if (broj3 == 9)
            {
                if (cx > cy)
                    konacno += cx * 1000000000;
                if (cy > cx)
                    konacno += cy * 1000000000;
                if (cx == cy)
                    konacno += cx * 1000000000 + (cx * 1000000000) * 10;
            }


            if (broj3 == 5)
            {
                if (nx > ny)
                    konacno += nx * 100000;
                if (ny > nx)
                    konacno += ny * 100000;
                if (nx == ny)
                    konacno += nx * 100000 + nx * 1000000;
            }
            if (broj3 == 6)
            {
                if (nx > ny)
                    konacno += nx * 1000000;
                if (ny > nx)
                    konacno += ny * 1000000;
                if (nx == ny)
                    konacno += nx * 1000000 + nx * 10000000;
            }
            if (broj3 == 7)
            {
                if (nx > ny)
                    konacno += nx * 10000000;
                if (ny > nx)
                    konacno += ny * 10000000;
                if (nx == ny)
                    konacno += nx * 10000000 + nx * 100000000;
            }
            if (broj3 == 8)
            {
                if (nx > ny)
                    konacno += nx * 100000000;
                if (ny > nx)
                    konacno += ny * 100000000;
                if (nx == ny)
                    konacno += nx * 100000000 + nx * 1000000000;
            }
            if (broj3 == 9)
            {
                if (nx > ny)
                    konacno += nx * 1000000000;
                if (ny > nx)
                    konacno += ny * 1000000000;
                if (nx == ny)
                    konacno += nx * 1000000000 + (nx * 1000000000) * 10;
            }


            if (broj3 == 5)
            {
                if (fx > fy)
                    konacno += fx * 100000;
                if (fy > fx)
                    konacno += fy * 100000;
                if (fx == fy)
                    konacno += fx * 100000 + fx * 1000000;
            }
            if (broj3 == 6)
            {
                if (fx > fy)
                    konacno += fx * 1000000;
                if (fy > fx)
                    konacno += fy * 1000000;
                if (fx == fy)
                    konacno += fx * 1000000 + fx * 10000000;
            }
            if (broj3 == 7)
            {
                if (fx > fy)
                    konacno += ax * 10000000;
                if (fy > fx)
                    konacno += ay * 10000000;
                if (fx == fy)
                    konacno += fx * 10000000 + fx * 100000000;
            }
            if (broj3 == 8)
            {
                if (fx > fy)
                    konacno += fx * 100000000;
                if (fy > fx)
                    konacno += fy * 100000000;
                if (fx == fy)
                    konacno += fx * 100000000 + fx * 1000000000;
            }
            if (broj3 == 9)
            {
                if (fx > fy)
                    konacno += fx * 1000000000;
                if (fy > fx)
                    konacno += fy * 1000000000;
                if (fx == fy)
                    konacno += fx * 1000000000 + (fx * 1000000000) * 10;
            }

            Console.WriteLine(konacno);


        }
    }
}