brtakoktrosttttttttttosafasfkalsfkodfdasiofhadfhasdsajfdsafoasodsafahaihfdisoadspapsapiosapdsajdipsahdhasuirhaeuifhhfkjgosooooooooodafdfioottttafdsafaddfuiasdjfjasdo
okat
tako
 aleksandrehteosidatedodam
evo
si
 goodbyeihopecontestisntsohar
oh
god
 duxidimkeetoivas
dd
odi
 hellodeninobrdo
od
hel
 ikbalturkeybelieveinyou
bal
kan
 zdule
didins
meinkraft
 cumurcumur
um
cur
 ikatanictisinajboljiuhrvatskojakoprictasovojaviseakotijedosadno
javise
sine
 zlobobermyfriendandthanksforhelp
de
for
 navijamzaradnickiastabidrugo
druzina
djavola
 saljivdzijasamjaneki
neki
ja
 bumbumdzejsikerol
bumbum
bum
 svetislavgajicpoznatijikaosvetaxxx
slavi
slavu
 princeofpersiayouhavegreatcontestbutinwrongtime
op
pera
 pozdravizamarkamatovicaaleksandracveticainenadaslagalicustanisica
vas
rad
 dreamoonhasonedream
no
no
 jankosustersicneceovoraditi
cosovic
oce
 milenicnikolaitisideotakmicenja
elem
nik
 touristyouaregreatguy
tourist
guy
 lukavpastaakojelukav
a
u
 xxxbbbcccoca
ca
cb
 aaaaaabababaaa
aa
a
 petryouaregoodandyouhavegoodblogs
blog
rega
 lebronnojameslebronprogrammers
je
bro
 mztskopjetisisampiosrcenaterenostaviajdezanaspobedi
mzt
optee
 gukimikazedauradimseminarskidodatnohumorhumor
dp
mrzime
 razredninjegosgrebovicdobarcoveklosbasketas
ne
go
 pozdravzamojeodeljenjeiprofesoreocudabudempetnula
bojan
cao
 damandicnenapravicheckerzeznulibise
man
ker
 pozdravizazenskudecunecuvasodvajatidaseneprotumacipogresno
cao
deco
 egoryouaregoodbutcantsolveeverythinginonehour
eat
your
 lemigazalemiolemilicomzalemljenje
lemi
zlo
 randomusername
umno
umno
 thisiscornercase
youhavetwolongerstrings
ibelivethatyoudontmissit
 oduleodule
xgrizx
ivanstosicprvi
 molimprofesorkuengleskogdamidapetjasamdobarcovekitrudimseiztogaiakosamoperisan
hvala
unapred
 djeneralmilomirstefanovic
radi
nesto
 balsabratepozdravimajudevojku
oj
zdrav
 iwanttothanktomygrandmaheisveryimportantpersoninmylife
thanks
stanka

takotakotakotakotakoaaaaaaaaaaaaaaaaaaaaaabddddddddddddddddddeffffffffffffffffffghhhhhhhhhiiiiiiiiijjjjjloooooooooooooooooppppprrrssssssssssssssssssssstttttttttttuuu
 siaaaaddddeeeehklmnoorstt
 ohohgodabceeeiinnooprsssttty
 odiadeeiikmstuvx
 ododhelbeilnnor
 kanbbeeeeiiikllortuuvyy
 deluz
 umumcurcur
 sinesineaaaaaaaaabccddhiiiiiijjjjjkkkklnooooooooprrssstttttuvvv
 dedeforforaabbehhikllmnnnoprstyz
 druzinaaaaaabcdgiiijkmnorstv
 nekijajajaadiilmssvz
 bumbumdeeijklorsz
 slaviaaaaceegiiijjknoopsstttvvxxxz
 peraperaabcceeeefgghiiiimnnnnoooorrsstttttuuvwy
 vasvasvasradradradaaaaaaaaaaccccceeegiiiiiiikklllmmnnnnoopstttuzz
 nonoaaaddeeehmmorrs
 oceoceaadeiiijknnorrsssttuv
 elemniknikaaaccdeiiiiijlmnoostt
 touristguyguyaaeeorrt
 aaaaauuejkkkllopstvv
 cacbcbcboxxx
 aaaaaaaaaaabbb
 blogregaregaadddehnoooooopstuuvyy
 jebrobroaaeeegllmmmnnnooprrrss
 mztopteeopteeopteeaaaaaabcddiiiiijjkmnnnorrssssssvz
 mrzimeaaaaaddddeghhiiiikkkmmmnnoooorrrsstuuuu
 nenegogoaaaabbbccddeeeiijkklooorrrrsssstvvz
 bojancaoaaddddeeeeeeeefijjllmmnooooppprrrstuuuvzz
 mankeraaabcccddeeeehiiiilnnnprsuvzz
 decodecodecoaaaaaaadeeegiiijkmnnnnooppprrrssssttuuuuvvvzzz
 eateatyouryourbcdeeeeggghhiilnnnnooooorrstuvv
 lemilemilemilemizlozloaaaceegjjmn
 umnoaadeemnrrs
 acceehiinorrssst
 ddeelloouu
 unapredunapredaaaaaaabcddeeeeefgggiiiiiiijkkkkllmmmmmmoooooooooprrrsssssstttvz
 radinestoaceefiijllmmnorv
 ojojzdravaaaabbdeeiklmprstuuv
 stankaaaadeeeefghhiiiiilmmmmnnnnnoooopprrrrstttttvwyyy

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
static String s;
static String str1;
static String str2;
static int[] num = new int[26];
static int[] num2 = new int[26];
static int[] tmp1 = new int[26];
static int[] tmp2 = new int[26];
static StringBuilder sb = new StringBuilder();
static StringBuilder sb2 = new StringBuilder();
static int moves1 = 0;
static int moves2 =0;
	public static void main(String[]args) throws Throwable{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		s = br.readLine();
		
		for(int i=0;i<s.length();i++){
			num[s.charAt(i)-'a']++;
			num2[s.charAt(i)-'a']++;
			tmp1[s.charAt(i)-'a']++;
			tmp2[s.charAt(i)-'a']++;
		}
	str1 = br.readLine();
	str2 = br.readLine();
	
	while(true){
	boolean invalid = false;
	for(int i=0;i<str1.length();i++){
		if(tmp1[str1.charAt(i)-'a']>0){
			
			tmp1[str1.charAt(i)-'a']--;
			
		}
		else invalid = true;
		if(invalid)break;
	}

	if(invalid) break;
	moves1++;
	for(int i=0;i<str1.length();i++){
		sb.append(str1.charAt(i));
		num[str1.charAt(i)-'a']--;
	}
	}
	for(int i=0;i<26;i++) tmp1[i] = num[i];
	while(true){
	boolean invalid = false;
	for(int i=0;i<str2.length();i++){
		if(tmp1[str2.charAt(i)-'a']>0){
			tmp1[str2.charAt(i)-'a']--;
			
		}
		else invalid = true;
		if(invalid)break;
	}
	if(invalid) break;
	moves1++;
	for(int i=0;i<str2.length();i++){
		sb.append(str2.charAt(i));
		num[str2.charAt(i)-'a']--;
	}
	}
	for(int i=0;i<26;i++) tmp1[i] = num[i];
	
	for(int i=0;i<26;i++) while(num[i]>0){
		sb.append((char)(i+'a'));
		
		num[i]--;
	}
	
	
	
	while(true){
	boolean invalid = false;
	for(int i=0;i<str2.length();i++){
		if(tmp2[str2.charAt(i)-'a']>0){
			tmp2[str2.charAt(i)-'a']--;
		}
		else invalid = true;
		if(invalid)break;
	}
	if(invalid) break;
	moves2++;
	for(int i=0;i<str2.length();i++){
		sb2.append(str2.charAt(i));
		num2[str2.charAt(i)-'a']--;
	}
	}
	for(int i=0;i<26;i++) tmp2[i] = num2[i];
	
	while(true){
		boolean invalid = false;
		for(int i=0;i<str1.length();i++){
			if(tmp2[str1.charAt(i)-'a']>0){
				tmp2[str1.charAt(i)-'a']--;
			}else invalid = true;
			if(invalid)break;
		}
		if(invalid) break;
		moves2++;
		for(int i=0;i<str1.length();i++){
			sb2.append(str1.charAt(i));
			num2[str1.charAt(i)-'a']--;
		}
		}
	for(int i=0;i<26;i++) while(num2[i]>0){
		sb2.append((char)(i+'a'));
		num2[i]--;
	}
	
	if(moves1>moves2) {
		System.out.print(sb);
	}
	else System.out.print(sb2);
	
	}
}
