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;
bool DBG;
struct dbg {
  template <typename T>
  dbg& operator,(const T& v) {
    if (DBG) cerr << v << " ";
    return *this;
  }
  ~dbg() {
    if (DBG) cerr << endl;
  }
};
int main(int argc, char const* argv[]) {
  DBG = (argc > 1 && *argv[1]);
  string s, b, c;
  cin >> s >> b >> c;
  int f[26], F[26], f2[26], f3[26];
  for (int i = 0; i < 26; ++i) f[i] = F[i] = f2[i] = f3[i] = 0;
  for (int i = 0; i < s.length(); ++i) {
    f[s[i] - 'a']++;
    F[s[i] - 'a']++;
  }
  for (int i = 0; i < b.length(); ++i) f2[b[i] - 'a']++;
  for (int i = 0; i < c.length(); ++i) f3[c[i] - 'a']++;
  int ans1, ans2;
  int ansb1 = 1e9, ansc1 = 1e9;
  for (int i = 0; i < 26; ++i)
    if (f2[i]) ansb1 = min(ansb1, f[i] / f2[i]);
  if (ansb1 != 1e9) {
    for (int i = 0; i < 26; ++i)
      if (f2[i]) f[i] -= ansb1 * f2[i];
  }
  for (int i = 0; i < 26; ++i)
    if (f3[i]) ansc1 = min(ansc1, f[i] / f3[i]);
  if (ansc1 != 1e9) {
    for (int i = 0; i < 26; ++i)
      if (f3[i]) f[i] -= ansc1 * f3[i];
  }
  ans1 = ansb1 + ansc1;
  assert(ans1 < 1e9);
  int ansb2 = 1e9, ansc2 = 1e9;
  for (int i = 0; i < 26; ++i)
    if (f3[i]) ansc2 = min(ansc2, F[i] / f3[i]);
  if (ansc2 != 1e9) {
    for (int i = 0; i < 26; ++i)
      if (f3[i]) F[i] -= ansc2 * f3[i];
  }
  for (int i = 0; i < 26; ++i)
    if (f2[i]) ansb2 = min(ansb2, F[i] / f2[i]);
  if (ansb2 != 1e9) {
    for (int i = 0; i < 26; ++i)
      if (f2[i]) F[i] -= ansb2 * f2[i];
  }
  ans2 = ansb2 + ansc2;
  assert(ans2 < 1e9);
  if (ans1 > ans2) {
    for (int i = 0; i < ansb1 && ansb1 != 1e9; ++i) cout << b;
    for (int i = 0; i < ansc1 && ansc1 != 1e9; ++i) cout << c;
    for (int i = 0; i < 26; ++i)
      if (f[i])
        while (f[i]--) cout << (char)(i + 'a');
    cout << endl;
  } else {
    for (int i = 0; i < ansb2 && ansb2 != 1e9; ++i) cout << b;
    for (int i = 0; i < ansc2 && ansc2 != 1e9; ++i) cout << c;
    for (int i = 0; i < 26; ++i)
      if (F[i])
        while (F[i]--) cout << (char)(i + 'a');
    cout << endl;
  }
  return 0;
}
