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

namespace ConsoleApp11
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Unesite X");
            int X = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Unesite Y");
            int Y = Convert.ToInt32(Console.ReadLine());
            int brcX = 1;
            int brcY = 1;
            int tempX = 0;
            int tempY = 0;
            int Z = 0;
            bool nullCheck = false;

            Console.WriteLine();
            tempX = X;
            while(X > 9)
            {
                X = X / 10;
                brcX++;
            }
            X = tempX;

            tempY = Y;
            while (Y > 9)
            {
                Y = Y / 10;
                brcY++;
            }
            Y = tempY;

            tempX = 0;
            tempY = 0;
            for(int i = 1; i < (brcX + 1) || i < (brcY + 1); i++)
            {
                tempX = X % 10;             
                tempY = Y % 10;

                if (X == tempX || Y == tempY)
                {
                    nullCheck = true;
                }

                if (tempX > tempY)
                {
                    Z += Convert.ToInt32(tempX * Math.Pow(10, i));                    
                }
                if (tempX < tempY)
                {
                    Z += Convert.ToInt32(tempY * Math.Pow(10, i));
                }
                if (tempX == tempY)
                {
                    if (nullCheck == false)
                    {
                        Z += Convert.ToInt32(tempX * Math.Pow(10, i));
                        i++;
                        Z += Convert.ToInt32(tempX * Math.Pow(10, i));
                        brcX++;
                        brcY++;
                    }
                    else
                    {
                        Z += Convert.ToInt32(tempX * Math.Pow(10, i));
                    }
                }
                X /= 10;
                Y /= 10;                
            }

            Z /= 10;

            Console.WriteLine();
            Console.WriteLine("Sudareni broj je " + (Z));

            Console.ReadLine();
        }
    }
}