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

#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100010], a[100010], b[100010];
  long long int nos[26] = {0}, i, lens = 0, noa[26] = {0}, nob[26] = {0},
                lena = 0, lenb = 0, count1 = 0, start = 0, counta = 0,
                countb = 0, j, nos1[26] = {0}, counta1 = 0, countb1 = 0;
  cin >> s >> a >> b;
  for (i = 0; s[i] != '\0'; i++) {
    nos[s[i] - 'a']++;
    lens++;
  }
  for (j = 0; j < 26; j++) {
    nos1[j] = nos[j];
  }
  for (i = 0; a[i] != '\0'; i++) {
    noa[a[i] - 'a']++;
    lena++;
  }
  for (i = 0; b[i] != '\0'; i++) {
    nob[b[i] - 'a']++;
    lenb++;
  }
  while (count1 == 0) {
    count1 = 0;
    for (i = 0; i < 26; i++) {
      if (noa[i] > nos[i]) {
        count1++;
      }
    }
    if (count1 == 0) {
      counta++;
      for (i = 0; i < 26; i++) {
        nos[i] = nos[i] - noa[i];
      }
    }
  };
  count1 = 0;
  while (count1 == 0) {
    count1 = 0;
    for (i = 0; i < 26; i++) {
      if (nob[i] > nos[i]) {
        count1++;
      }
    }
    if (count1 == 0) {
      countb++;
      for (i = 0; i < 26; i++) {
        nos[i] = nos[i] - nob[i];
      }
    }
  };
  count1 = 0;
  while (count1 == 0) {
    count1 = 0;
    for (i = 0; i < 26; i++) {
      if (nob[i] > nos1[i]) {
        count1++;
      }
    }
    if (count1 == 0) {
      countb1++;
      for (i = 0; i < 26; i++) {
        nos1[i] = nos1[i] - nob[i];
      }
    }
  };
  count1 = 0;
  while (count1 == 0) {
    count1 = 0;
    for (i = 0; i < 26; i++) {
      if (noa[i] > nos1[i]) {
        count1++;
      }
    }
    if (count1 == 0) {
      counta1++;
      for (i = 0; i < 26; i++) {
        nos1[i] = nos1[i] - noa[i];
      }
    }
  };
  if (counta >= countb1) {
    for (i = 0; i < counta; i++) {
      cout << a;
    }
    for (i = 0; i < countb; i++) {
      cout << b;
    }
    for (i = 0; i < 26; i++) {
      if (nos[i] > 0) {
        for (j = 0; j < nos[i]; j++) {
          cout << char(i + 'a');
        }
      }
    }
  } else if (counta < countb1) {
    for (i = 0; i < countb1; i++) {
      cout << b;
    }
    for (i = 0; i < counta1; i++) {
      cout << a;
    }
    for (i = 0; i < 26; i++) {
      if (nos1[i] > 0) {
        for (j = 0; j < nos1[i]; j++) {
          cout << char(i + 'a');
        }
      }
    }
  }
  return 0;
}
