#include <iostream>

using namespace std;

int
main ()
{
  int x, y, xj, xd, xs, xh, yj, yd, ys, yh, brj,brd,brs,brh;
  cin >> x >> y;
  xj = x % 10;
  xd = ((x % 1000) / 10) % 10;
  xs = ((x % 1000) / 10) / 10;
  xh = x / 1000;
  yj = y % 10;
  yd = ((y % 1000) / 10) % 10;
  ys = ((y % 1000) / 10) / 10;
  yh = y / 1000;
  if (xj > yj)
    {
          brj = xj;
         }
    else{
      brj = yj;
    }
      if (xd > yd)
	{
	  brd = xd;
	}
      else
	{
	  brd = yd;
	}
	  if (xs > ys)
	    {
	      brs = xs;
	    }
	  else
	    {
	      brs = ys;
	    }
	    if (xh>yh){
    brh=xh;
    }
    else {
    brh=yh;
    }
    if (brh=0){
        cout<<brs<<brd<<brj;
    }
    else {
    cout<<brh<<brs<<brd<<brj;
    } 
    if (brh=0,brs=0){
        cout<<brd<<brj;
    }
    else {
    cout<<brh<<brs<<brd<<brj;
    } 
    if (brh=0,brs=0,brd=0){
        cout<<brd<<brj;
    }
    else {
    cout<<brh<<brs<<brd<<brj;
    } 
	      return 0;
	    }