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 kolo(string a, map<char, int> &m, int x) {
  map<char, int> n;
  for (char x = 'a'; x <= 'z'; x++) n[x] = 0;
  for (int(i) = (0); (i) < (a.length()); i++) n[a[i]]++;
  int mini = 1 << 25;
  for (char x = 'a'; x <= 'z'; x++)
    if (n[x]) mini = min(mini, m[x] / n[x]);
  mini = min(mini, x);
  for (char x = 'a'; x <= 'z'; x++) m[x] -= mini * n[x];
  return mini;
}
void dopis(map<char, int> m) {
  for (char x = 'a'; x <= 'z'; x++)
    for (int(i) = (0); (i) < (m[x]); i++) cout << x;
}
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  map<char, int> m, n1, n2, n3, n4;
  for (char x = 'a'; x <= 'z'; x++) m[x] = 0;
  for (int(i) = (0); (i) < (a.length()); i++) m[a[i]]++;
  int e1 = -1, e2 = -1;
  int x = -1, y = 20000;
  while (x + 1 < y) {
    n1 = m;
    int z = (x + y) / 2;
    int f1 = kolo(b, n1, z - 1);
    int f2 = kolo(c, n1, 1 << 25);
    if (f1 + f2 > e1 + e2) {
      e1 = f1;
      e2 = f2;
      n2 = n1;
    }
    n4 = m;
    int f11 = kolo(b, n4, z + 1);
    int f22 = kolo(c, n4, 1 << 25);
    if (f11 + f22 > e1 + e2) {
      e1 = f11;
      e2 = f22;
      n2 = n4;
    }
    n3 = m;
    int f111 = kolo(b, n3, z);
    int f222 = kolo(c, n3, 1 << 25);
    if (f111 + f222 > e1 + e2) {
      e1 = f111;
      e2 = f222;
      n2 = n3;
    }
    if (f1 + f2 > f111 + f222) {
      y = z;
    } else if (f11 + f22 > f111 + f222) {
      x = z;
    } else
      break;
  }
  x = 19990;
  y = 40000;
  while (x + 1 < y) {
    n1 = m;
    int z = (x + y) / 2;
    int f1 = kolo(b, n1, z - 1);
    int f2 = kolo(c, n1, 1 << 25);
    if (f1 + f2 > e1 + e2) {
      e1 = f1;
      e2 = f2;
      n2 = n1;
    }
    n4 = m;
    int f11 = kolo(b, n4, z + 1);
    int f22 = kolo(c, n4, 1 << 25);
    if (f11 + f22 > e1 + e2) {
      e1 = f11;
      e2 = f22;
      n2 = n4;
    }
    n3 = m;
    int f111 = kolo(b, n3, z);
    int f222 = kolo(c, n3, 1 << 25);
    if (f111 + f222 > e1 + e2) {
      e1 = f111;
      e2 = f222;
      n2 = n3;
    }
    if (f1 + f2 > f111 + f222) {
      y = z;
    } else if (f11 + f22 > f111 + f222) {
      x = z;
    } else
      break;
  }
  x = 39999;
  y = 70000;
  while (x + 1 < y) {
    n1 = m;
    int z = (x + y) / 2;
    int f1 = kolo(b, n1, z - 1);
    int f2 = kolo(c, n1, 1 << 25);
    if (f1 + f2 > e1 + e2) {
      e1 = f1;
      e2 = f2;
      n2 = n1;
    }
    n4 = m;
    int f11 = kolo(b, n4, z + 1);
    int f22 = kolo(c, n4, 1 << 25);
    if (f11 + f22 > e1 + e2) {
      e1 = f11;
      e2 = f22;
      n2 = n4;
    }
    n3 = m;
    int f111 = kolo(b, n3, z);
    int f222 = kolo(c, n3, 1 << 25);
    if (f111 + f222 > e1 + e2) {
      e1 = f111;
      e2 = f222;
      n2 = n3;
    }
    if (f1 + f2 > f111 + f222) {
      y = z;
    } else if (f11 + f22 > f111 + f222) {
      x = z;
    } else
      break;
  }
  x = 69990;
  y = 100008;
  while (x + 1 < y) {
    n1 = m;
    int z = (x + y) / 2;
    int f1 = kolo(b, n1, z - 1);
    int f2 = kolo(c, n1, 1 << 25);
    if (f1 + f2 > e1 + e2) {
      e1 = f1;
      e2 = f2;
      n2 = n1;
    }
    n4 = m;
    int f11 = kolo(b, n4, z + 1);
    int f22 = kolo(c, n4, 1 << 25);
    if (f11 + f22 > e1 + e2) {
      e1 = f11;
      e2 = f22;
      n2 = n4;
    }
    n3 = m;
    int f111 = kolo(b, n3, z);
    int f222 = kolo(c, n3, 1 << 25);
    if (f111 + f222 > e1 + e2) {
      e1 = f111;
      e2 = f222;
      n2 = n3;
    }
    if (f1 + f2 > f111 + f222) {
      y = z;
    } else if (f11 + f22 > f111 + f222) {
      x = z;
    } else
      break;
  }
  for (int(i) = (0); (i) < (e1); i++) cout << b;
  for (int(i) = (0); (i) < (e2); i++) cout << c;
  dopis(n2);
  cout << endl;
  return 0;
}
