#include <iostream>
using namespace std;

int main() {
	int x, y, jedX, desX, stotX, jedY, desY, stotY, hiljadaX, hiljadaY, dHiljX, dHiljY;
	cin >> x >> y;
	
	jedX = x % 10; desX = (x % 100) / 10; stotX = (x % 1000) / 100; hiljadaX = (x / 1000) % 10, dHiljX = x / 10000;
	jedY = y % 10; desY = (y % 100) / 10; stotY = (y % 1000) / 100; hiljadaY = (y / 1000) % 10; dHiljY = y / 10000;
	
	if (dHiljX > dHiljY)
		cout << dHiljX;
	else if (dHiljX == dHiljY && (dHiljX + dHiljY != 0))
		cout << dHiljX << dHiljY;
	else if ((dHiljX && dHiljY != 0))
		cout << dHiljY;	
		
	if (hiljadaX > hiljadaY)
		cout << hiljadaX;
	else if (hiljadaX == hiljadaY && (hiljadaX + hiljadaY != 0))
		cout << hiljadaX << hiljadaY;
	else if (!(hiljadaX > hiljadaY) && hiljadaY && hiljadaX != 0)
		cout << hiljadaY;
		
	if (stotX > stotY)
		cout << stotX;
	else if (stotX < stotY && (stotX && stotY) != 0)
		cout << stotX << stotY;
	else if (stotX || stotY != 0)
		cout << stotY;
		
	if (desX > desY)
		cout << desX;
	else if (desX == desY && (desX && desY != 0))
		cout << desX << desY;
	else if (!(desX > desY && (desX && desY != 0)))
		cout << desY;
		
	if (jedX > jedY)
		cout << jedX;
	else if (jedX == jedY && (jedX && jedY != 0))
		cout << jedX << jedY;
	else if (!(jedX > jedY && (jedX && jedY != 0)))
		cout << jedY;
		
	return 0;
}