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>
#pragma optimization_level 3
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e+9 + 7;
const ll INF = INT_MAX;
const int N = (int)2e+5 + 8;
string second, a, b;
int cnts[30], cnta[30], cntb[30];
void MAIN(int tc) {
  cin >> second >> a >> b;
  string ca = a, cb = b;
  int n = second.size(), na = a.size(), nb = b.size();
  second = "#" + second + "#";
  ;
  a = "#" + a + "#";
  ;
  b = "#" + b + "#";
  ;
  for (int i = 1; i <= n; i++) {
    cnts[second[i] - 'a' + 1]++;
  }
  for (int i = 1; i <= na; i++) {
    cnta[a[i] - 'a' + 1]++;
  }
  for (int i = 1; i <= nb; i++) {
    cntb[b[i] - 'a' + 1]++;
  }
  int geta = INF, getb = INF;
  for (int i = 1; i <= 26; i++) {
    if (cnta[i] == 0) continue;
    geta = min(geta, cnts[i] / cnta[i]);
  }
  if (geta == INF) geta = 0;
  for (int i = 1; i <= 26; i++) {
    if (cntb[i] == 0) continue;
    getb = min(getb, cnts[i] / cntb[i]);
  }
  if (getb == INF) getb = 0;
  int rema = INF, remb = INF;
  for (int i = 1; i <= 26; i++) {
    if (cnta[i] == 0) continue;
    rema = min(rema, (cnts[i] - getb * cntb[i]) / cnta[i]);
  }
  if (rema == INF) rema = 0;
  for (int i = 1; i <= 26; i++) {
    if (cntb[i] == 0) continue;
    remb = min(remb, (cnts[i] - geta * cnta[i]) / cntb[i]);
  }
  if (remb == INF) remb = 0;
  string res = "";
  if (geta + remb > getb + rema) {
    for (int i = 1; i <= geta; i++) res += ca;
    for (int i = 1; i <= remb; i++) res += cb;
    for (int i = 1; i <= 26; i++) {
      cnts[i] -= geta * cnta[i] + remb * cntb[i];
      res += string(cnts[i], char(i + 'a' - 1));
    }
  } else {
    for (int i = 1; i <= getb; i++) res += cb;
    for (int i = 1; i <= rema; i++) res += ca;
    for (int i = 1; i <= 26; i++) {
      cnts[i] -= getb * cntb[i] + rema * cnta[i];
      res += string(cnts[i], char(i + 'a' - 1));
    }
  }
  cout << res << "\n";
  ;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout << setprecision(10);
  int test_cases = 1;
  for (int i = 1; i <= test_cases; i++) {
    MAIN(i);
  }
}
