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;
char q[100005];
char m[100005];
int vis[100005];
int mi = 1000000007, mii = 1000000007;
char p[100005];
int vis2[100005];
char pp[100005];
int k;
int mx;
void f(char a[], int len1, char b[], int len2, char c[], int len3) {
  int cnt[200];
  int tot[200];
  int x[200], tot2[200];
  memset(tot, 0, sizeof(tot));
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < len2; i++) cnt[b[i]]++;
  for (int i = 0; i < len1; i++) {
    if (cnt[a[i]]) tot[a[i]]++;
  }
  int m = 1000000007;
  for (int i = 0; i < 200; i++) {
    if (cnt[i]) {
      m = min(m, tot[i] / cnt[i]);
    }
  }
  int tmp[200];
  for (int mi2 = 0; mi2 <= m; mi2++) {
    memset(x, 0, sizeof(x));
    memset(tot2, 0, sizeof(tot2));
    memset(tmp, 0, sizeof(tmp));
    for (int i = 0; i < 200; i++) {
      if (cnt[i]) {
        tmp[i] = cnt[i] * mi2;
      }
    }
    k = 0;
    for (int i = 0; i < len1; i++) {
      if (cnt[a[i]] && tmp[a[i]]) {
        tmp[a[i]]--;
      } else {
        q[k++] = a[i];
      }
    }
    for (int i = 0; i < len3; i++) x[c[i]]++;
    for (int i = 0; i < k; i++) {
      if (x[q[i]]) tot2[q[i]]++;
    }
    int mii2 = 1000000007;
    for (int i = 0; i < 200; i++) {
      if (x[i]) {
        mii2 = min(mii2, tot2[i] / x[i]);
      }
    }
    if (mi2 + mii2 > mx) {
      memset(vis, 0, sizeof(vis));
      memset(tmp, 0, sizeof(tmp));
      for (int i = 0; i < 200; i++) {
        if (x[i]) {
          tmp[i] = x[i] * mii2;
        }
      }
      for (int i = 0; i < k; i++) {
        if (x[q[i]] && tmp[q[i]]) {
          tmp[q[i]]--;
          vis[i] = 1;
        }
      }
      mx = mi2 + mii2;
      mi = mi2;
      mii = mii2;
    }
  }
}
int main() {
  char a[100005], b[100005], c[100005];
  cin >> a >> b >> c;
  mx = -1;
  int len1 = strlen(a);
  int len2 = strlen(b);
  int len3 = strlen(c);
  mi = 0, mii = 0;
  f(a, len1, b, len2, c, len3);
  for (int i = 0; i < k; i++) p[i] = q[i];
  for (int i = 0; i < k; i++) vis2[i] = vis[i];
  int aa = mi, bb = mii;
  int kk = k;
  f(a, len1, c, len3, b, len2);
  if (mi + mii < aa + bb) {
    mi = aa, mii = bb, k = kk;
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < k; i++) vis[i] = vis2[i];
    for (int i = 1; i <= mi; i++) cout << b;
    for (int i = 1; i <= mii; i++) cout << c;
    for (int i = 0; i < k; i++) {
      if (!vis[i]) cout << p[i];
    }
    cout << endl;
  } else {
    for (int i = 0; i < k; i++) p[i] = q[i];
    for (int i = 1; i <= mi; i++) cout << c;
    for (int i = 1; i <= mii; i++) cout << b;
    for (int i = 0; i < k; i++) {
      if (!vis[i]) cout << p[i];
    }
    cout << endl;
  }
}
