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;
const int NMAX = 10e5 + 2;
vector<pair<char, char> > v;
map<char, int> mma, mmb, mmc;
map<char, int>::iterator it;
set<string> second;
deque<int> d;
int main() {
  ios::sync_with_stdio(false);
  long long n, m, an = 0;
  string a, b, c;
  cin >> a >> b >> c;
  if (a.size() < b.size() && a.size() < c.size()) {
    cout << a;
    return 0;
  }
  for (int i = 0; i < a.size(); ++i) {
    mma[a[i]]++;
  }
  for (int i = 0; i < b.size(); ++i) {
    mmb[b[i]]++;
  }
  for (int i = 0; i < c.size(); ++i) {
    mmc[c[i]]++;
  }
  int mnb = 1005000, mnc = 1005000;
  bool bb = true, cc = true;
  for (it = mmb.begin(); it != mmb.end(); ++it) {
    if (mma[it->first] / it->second > 0) {
      if (mma[it->first] / it->second < mnb) mnb = mma[it->first] / it->second;
    } else
      bb = false;
  }
  for (it = mmc.begin(); it != mmc.end(); ++it) {
    if (mma[it->first] / it->second > 0) {
      if (mma[it->first] / it->second < mnc) mnc = mma[it->first] / it->second;
    } else
      cc = false;
  }
  if (bb && cc) {
    if (mnc > mnb) {
      for (it = mmc.begin(); it != mmc.end(); ++it) {
        mma[it->first] -= mnc * it->second;
      }
      while (mnc) {
        cout << c;
        mnc--;
      }
      mnb = 1005000;
      for (it = mmb.begin(); it != mmb.end(); ++it) {
        if (mma[it->first] / it->second > 0) {
          if (mma[it->first] / it->second < mnb)
            mnb = mma[it->first] / it->second;
        } else {
          bb = false;
          break;
        }
      }
      if (bb) {
        for (it = mmb.begin(); it != mmb.end(); ++it) {
          mma[it->first] -= mnb * it->second;
        }
        while (mnb) {
          cout << b;
          mnb--;
        }
      }
      for (it = mma.begin(); it != mma.end(); ++it) {
        while (it->second > 0) {
          cout << it->first;
          mma[it->first]--;
        }
      }
    } else {
      for (it = mmb.begin(); it != mmb.end(); ++it) {
        mma[it->first] -= mnb * it->second;
      }
      while (mnb) {
        cout << b;
        mnb--;
      }
      mnc = 1005000;
      for (it = mmc.begin(); it != mmc.end(); ++it) {
        if (mma[it->first] / it->second > 0) {
          if (mma[it->first] / it->second < mnc)
            mnc = mma[it->first] / it->second;
        } else {
          cc = false;
          break;
        }
      }
      if (cc) {
        for (it = mmc.begin(); it != mmc.end(); ++it) {
          mma[it->first] -= mnc * it->second;
        }
        while (mnc) {
          cout << c;
          mnc--;
        }
      }
      for (it = mma.begin(); it != mma.end(); ++it) {
        while (it->second > 0) {
          cout << it->first;
          mma[it->first]--;
        }
      }
    }
  } else if (bb) {
    for (it = mmb.begin(); it != mmb.end(); ++it) {
      mma[it->first] -= mnb * it->second;
    }
    while (mnb) {
      cout << b;
      mnb--;
    }
    for (it = mma.begin(); it != mma.end(); ++it) {
      while (it->second > 0) {
        cout << it->first;
        mma[it->first]--;
      }
    }
  } else if (cc) {
    for (it = mmc.begin(); it != mmc.end(); ++it) {
      mma[it->first] -= mnc * it->second;
    }
    while (mnc) {
      cout << c;
      mnc--;
    }
    for (it = mma.begin(); it != mma.end(); ++it) {
      while (it->second > 0) {
        cout << it->first;
        mma[it->first]--;
      }
    }
  } else
    cout << a;
  return 0;
}
