int Num1 = Convert.ToInt32(Console.ReadLine());
int Num2 = Convert.ToInt32(Console.ReadLine());


int Num1J  = Num1 % 10;
int Num2J  = Num2 % 10;

int Num1D  = ((Num1 - Num1J)/10)%10;
int Num2D  = ((Num2 - Num2J)/10)%10;

int Num1S  = (((Num1 - Num1J - Num1D * 10) / 100) % 10);
int Num2S  = (((Num2 - Num2J - Num2D * 10) / 100) % 10);

int Num1H  = (((Num1 - Num1J - Num1D * 10 - Num1S * 100) / 1000) % 10);
int Num2H  = (((Num2 - Num2J - Num2D * 10 - Num2S * 100) / 1000) % 10);

int Num1DH = (((Num1 - Num1J - Num1D * 10 - Num1S * 100 - Num1H * 1000) / 10000) % 10);
int Num2DH = (((Num2 - Num2J - Num2D * 10 - Num2S * 100 - Num2H * 1000) / 10000) % 10);

int Num1SH = (((Num1 - Num1J - Num1D * 10 - Num1S * 100 - Num1H * 1000 - Num1DH * 10000) / 100000) % 10);
int Num2SH = (((Num2 - Num2J - Num2D * 10 - Num2S * 100 - Num2H * 1000 - Num2DH * 10000) / 100000) % 10);

int Num1M  =  (((Num1 - Num1J - Num1D * 10 - Num1S * 100 - Num1H * 1000 - Num1DH * 10000 - Num1SH * 100000) / 1000000) % 10);
int Num2M  =  (((Num2 - Num2J - Num2D * 10 - Num2S * 100 - Num2H * 1000 - Num2DH * 10000 - Num2SH * 100000) / 1000000) % 10);

int Num1MD = (((Num1 - Num1J - Num1D * 10 - Num1S * 100 - Num1H * 1000 -
    Num1DH * 10000 - Num1SH * 100000 - Num1M * 1000000) / 10000000) % 10);
int Num2MD = (((Num2 - Num2J - Num2D * 10 - Num2S * 100 - Num2H * 1000 -
    Num2DH * 10000 - Num2SH * 100000 - Num2M * 1000000) / 10000000) % 10);

int Num1MS = (((Num1 - Num1J - Num1D * 10 - Num1S * 100 - Num1H * 1000 -
    Num1DH * 10000 - Num1SH * 100000 - Num1M * 1000000 - Num1MD * 10000000) / 100000000) % 10);
int Num2MS = (((Num2 - Num2J - Num2D * 10 - Num2S * 100 - Num2H * 1000 -
    Num2DH * 10000 - Num2SH * 100000 - Num2M * 1000000 - Num2MD * 10000000) / 100000000) % 10);

int Num1B = (((Num1 - Num1J - Num1D * 10 - Num1S * 100 - Num1H * 1000 -
    Num1DH * 10000 - Num1SH * 100000 - Num1M * 1000000 - Num1MD * 10000000 - Num1MS * 100000000) / 1000000000) % 10);
int Num2B = (((Num2 - Num2J - Num2D * 10 - Num2S * 100 - Num2H * 1000 -
    Num2DH * 10000 - Num2SH * 100000 - Num2M * 1000000 - Num2MD * 10000000 - Num2MS * 100000000) / 1000000000) % 10);


string NUM = "";

if (Num1J > Num2J)
{
    NUM = Convert.ToString(Num1J) + NUM;

}
else if (Num2J > Num1J)
{
    NUM = Convert.ToString(Num2J) + NUM;
} 
else if (Num2J == Num1J)
{
    if (Num1J + Num1D + Num1S + Num1H + Num1DH + Num1SH + Num1M + Num1MD + Num1MS + Num1B == 0 ||
        Num2J + Num2D + Num2S + Num2H + Num2DH + Num2SH + Num2M + Num2MD + Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1J) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1J) + NUM;
        NUM = Convert.ToString(Num2J) + NUM;
    }
}

//-- J

if (Num1D > Num2D)
{
    NUM = Convert.ToString(Num1D) + NUM;

}
else if (Num2D > Num1D)
{
    NUM = Convert.ToString(Num2D) + NUM;
}
else if (Num2D == Num1D)
{
    if (  Num1D + Num1S + Num1H + Num1DH + Num1SH + Num1M + Num1MD + Num1MS + Num1B == 0 ||
          Num2D + Num2S + Num2H + Num2DH + Num2SH + Num2M + Num2MD + Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1D) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1D) + NUM;
        NUM = Convert.ToString(Num2D) + NUM;
    }
}

//-- D

if (Num1S > Num2S)
{
    NUM = Convert.ToString(Num1S) + NUM;

}
else if (Num2S > Num1S)
{
    NUM = Convert.ToString(Num2S) + NUM;
}
else if (  Num1S + Num1H + Num1DH + Num1SH + Num1M + Num1MD + Num1MS + Num1B == 0 ||
           Num2S + Num2H + Num2DH + Num2SH + Num2M + Num2MD + Num2MS + Num2B == 0)
{
    if (Num1 == Num1D * 10 + Num1J + Num1S *100 || Num2 == Num2D * 10 + Num2J + Num2S* 100)
    {
        NUM = Convert.ToString(Num1S) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1S) + NUM;
        NUM = Convert.ToString(Num2S) + NUM;
    }
}

//-- S

if (Num1H > Num2H)
{
    NUM = Convert.ToString(Num1H) + NUM;

}
else if (Num2H > Num1H)
{
    NUM = Convert.ToString(Num2H) + NUM;
}
else if (Num2H == Num1H )
{
    if (  Num1H + Num1DH + Num1SH + Num1M + Num1MD + Num1MS + Num1B == 0 ||
          Num2H + Num2DH + Num2SH + Num2M + Num2MD + Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1H) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1H) + NUM;
        NUM = Convert.ToString(Num2H) + NUM;
    }
}

// -- H

if (Num1DH > Num2DH)
{
    NUM = Convert.ToString(Num1DH) + NUM;

}
else if (Num2DH > Num1DH)
{
    NUM = Convert.ToString(Num2DH) + NUM;
}
else if (Num2DH == Num1DH )
{
    if (Num1DH + Num1SH + Num1M + Num1MD + Num1MS + Num1B == 0 ||
        Num2DH + Num2SH + Num2M + Num2MD + Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1DH) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1DH) + NUM;
        NUM = Convert.ToString(Num2DH) + NUM;
    }
}

// -- DH

if (Num1SH > Num2SH)
{
    NUM = Convert.ToString(Num1SH) + NUM;

}
else if (Num2SH > Num1SH)
{
    NUM = Convert.ToString(Num2SH) + NUM;
}
else if (Num2SH == Num1SH)
{
    if (  Num1SH + Num1M + Num1MD + Num1MS + Num1B == 0 ||
          Num2SH + Num2M + Num2MD + Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1SH) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1SH) + NUM;
        NUM = Convert.ToString(Num2SH) + NUM;
    }
}

// -- SH

if (Num1M > Num2M)
{
    NUM = Convert.ToString(Num1M) + NUM;

}
else if (Num2M > Num1M)
{
    NUM = Convert.ToString(Num2M) + NUM;
}
else if (Num2M == Num1M)
{
    if (  Num1M + Num1MD + Num1MS + Num1B == 0 ||
          Num2M + Num2MD + Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1M) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1M) + NUM;
        NUM = Convert.ToString(Num2M) + NUM;
    }
}

// -- M

if (Num1MD > Num2MD)
{
    NUM = Convert.ToString(Num1MD) + NUM;

}
else if (Num2MD > Num1MD)
{
    NUM = Convert.ToString(Num2MD) + NUM;
}
else if (Num2MD == Num1MD)
{
    if (Num1MD + Num1MS + Num1B == 0 ||
        Num2MD + Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1MD) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1MD) + NUM;
        NUM = Convert.ToString(Num2MD) + NUM;
    }
}

// -- MD

if (Num1MS > Num2MS)
{
    NUM = Convert.ToString(Num1MS) + NUM;

}
else if (Num2MS > Num1MS)
{
    NUM = Convert.ToString(Num2MS) + NUM;
}
else if (Num2MS == Num1MS)
{
    if  ( Num1MS + Num1B == 0 ||
          Num2MS + Num2B == 0)
    {
        NUM = Convert.ToString(Num1MS) + NUM;
    }
    else
    {
        NUM = Convert.ToString(Num1MS) + NUM;
        NUM = Convert.ToString(Num2MS) + NUM;
    }
}

// -- MS

if (Num1B > Num2B)
{
    NUM = Convert.ToString(Num1B) + NUM;

}
else if (Num2B > Num1B)
{
    NUM = Convert.ToString(Num2B) + NUM;
}
else if (Num2B == Num1B)
{
    NUM = Convert.ToString(Num1B) + NUM;
    NUM = Convert.ToString(Num2B) + NUM;
}

// -- B



long NUMG = Convert.ToInt64(NUM);




Console.WriteLine(NUMG);