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 generateb(int a, long int nos[], long int noa[], long int nob[]) {
  int i, minb = 100002;
  for (i = 0; i < 26; i++) {
    nos[i] = nos[i] - (noa[i] * a);
  }
  for (i = 0; i < 26; i++) {
    if (nob[i] != 0) {
      if (nos[i] / nob[i] < minb) {
        minb = nos[i] / nob[i];
      }
    }
  }
  return minb;
}
int generatea(int b, long int nos[], long int noa[], long int nob[]) {
  int i, mina = 100002;
  for (i = 0; i < 26; i++) {
    nos[i] = nos[i] - (nob[i] * b);
  }
  for (i = 0; i < 26; i++) {
    if (noa[i] != 0) {
      if (nos[i] / noa[i] < mina) {
        mina = nos[i] / noa[i];
      }
    }
  }
  return mina;
}
int main() {
  char s[100010], a[100010], b[100010];
  long int nos[26] = {0}, i, lens = 0, noa[26] = {0}, nob[26] = {0}, lena = 0,
           lenb = 0, j, nos1[26] = {0}, mina = 100002, counta, countb, max = -1,
           maxa, maxb, minb = 100002, r;
  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++;
  }
  for (i = 0; i < 26; i++) {
    if (noa[i] != 0) {
      if (nos[i] / noa[i] < mina) {
        mina = nos[i] / noa[i];
      }
    }
  }
  for (i = 0; i <= mina; i++) {
    countb = generateb(i, nos, noa, nob);
    for (j = 0; j < 26; j++) {
      nos[j] = nos1[j];
    }
    if (i + countb > max) {
      max = i + countb;
      maxa = i;
      maxb = countb;
    }
  }
  for (i = 0; i < 26; i++) {
    if (nob[i] != 0) {
      if (nos[i] / nob[i] < minb) {
        minb = nos[i] / nob[i];
      }
    }
  }
  for (i = 0; i <= minb; i++) {
    counta = generatea(i, nos, noa, nob);
    for (j = 0; j < 26; j++) {
      nos[j] = nos1[j];
    }
    if (i + counta > max) {
      max = i + counta;
      maxb = i;
      maxa = counta;
    }
  }
  for (i = 0; i < maxa; i++) {
    cout << a;
  }
  for (i = 0; i < maxb; i++) {
    cout << b;
  }
  for (i = 0; i < 26; i++) {
    nos[i] = nos[i] - (maxa * noa[i]) - (maxb * nob[i]);
  }
  for (i = 0; i < 26; i++) {
    for (j = 0; j < nos[i]; j++) {
      cout << char(i + 'a');
    }
  }
  return 0;
}
