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 a[100005], b[100005], c[100005], s1[100005], s2[100005];
int func2(int n, int x, int y) {
  int i;
  int count = 0;
  int ch[26] = {0};
  for (i = 0; i < n; i++) {
    ch[a[i] - 'a']++;
  }
  int in = 0;
  int flg;
  int c1[26] = {0};
  for (i = 0; i < y; i++) {
    c1[c[i] - 'a']++;
  }
  while (1) {
    flg = 0;
    for (i = 0; i < 26; i++) {
      if (ch[i] < c1[i]) {
        flg = 1;
        break;
      }
    }
    if (!flg) {
      count++;
      for (i = 0; i < y; i++) {
        ch[c[i] - 'a']--;
        s2[in++] = c[i];
      }
    } else
      break;
  }
  int b1[26] = {0};
  for (i = 0; i < x; i++) {
    b1[b[i] - 'a']++;
  }
  while (1) {
    flg = 0;
    for (i = 0; i < 26; i++) {
      if (ch[i] < b1[i]) {
        flg = 1;
        break;
      }
    }
    if (!flg) {
      count++;
      for (i = 0; i < x; i++) {
        ch[b[i] - 'a']--;
        s2[in++] = b[i];
      }
    } else
      break;
  }
  for (i = 0; i < 26; i++) {
    while (ch[i] > 0) {
      s2[in++] = i + 'a';
      ch[i]--;
    }
  }
  s2[in] = '\0';
  return count;
}
int func1(int n, int x, int y) {
  int i;
  int count = 0;
  int ch[26] = {0};
  for (i = 0; i < n; i++) {
    ch[a[i] - 'a']++;
  }
  int in = 0;
  int flg;
  int b1[26] = {0};
  for (i = 0; i < x; i++) {
    b1[b[i] - 'a']++;
  }
  while (1) {
    flg = 0;
    for (i = 0; i < 26; i++) {
      if (ch[i] < b1[i]) {
        flg = 1;
        break;
      }
    }
    if (!flg) {
      count++;
      for (i = 0; i < x; i++) {
        ch[b[i] - 'a']--;
        s1[in++] = b[i];
      }
    } else
      break;
  }
  int c1[26] = {0};
  for (i = 0; i < y; i++) {
    c1[c[i] - 'a']++;
  }
  while (1) {
    flg = 0;
    for (i = 0; i < 26; i++) {
      if (ch[i] < c1[i]) {
        flg = 1;
        break;
      }
    }
    if (!flg) {
      count++;
      for (i = 0; i < y; i++) {
        ch[c[i] - 'a']--;
        s1[in++] = c[i];
      }
    } else
      break;
  }
  for (i = 0; i < 26; i++) {
    while (ch[i] > 0) {
      s1[in++] = i + 'a';
      ch[i]--;
    }
  }
  s1[in] = '\0';
  return count;
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, j;
  int n, x, y;
  cin >> a >> b >> c;
  n = strlen(a);
  x = strlen(b);
  y = strlen(c);
  if (b == c) {
    int count1 = func1(n, x, y);
    cout << s1 << endl;
  } else {
    int count1 = func1(n, x, y);
    int count2 = func2(n, x, y);
    if (count1 > count2)
      cout << s1 << endl;
    else
      cout << s2 << endl;
  }
}
