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 main() {
  string str, str1, str2;
  cin >> str;
  cin >> str1;
  cin >> str2;
  int i, j, temp;
  char arr[100005];
  int freq3[27], freq1[27], freq2[27], freq[27];
  int counter1;
  int counter2;
  for (i = 0; i < 27; i++) {
    freq[i] = 0;
    freq1[i] = 0;
    freq2[i] = 0;
    freq3[i] = 0;
  }
  for (i = 0; i < str.length(); i++) {
    freq[str[i] - 'a']++;
    freq3[str[i] - 'a']++;
  }
  for (i = 0; i < str1.length(); i++) {
    freq1[str1[i] - 'a']++;
  }
  for (i = 0; i < str2.length(); i++) {
    freq2[str2[i] - 'a']++;
  }
  int fact1 = INT_MAX;
  int fact2 = INT_MAX;
  for (i = 0; i < 27; i++) {
    if (freq1[i] != 0) {
      temp = freq[i] / freq1[i];
      if (temp < fact1) fact1 = temp;
    }
  }
  int suba;
  for (i = 0; i < 27; i++) {
    if (freq1[i] != 0) {
      freq[i] = freq[i] - freq1[i] * fact1;
    }
  }
  for (i = 0; i < 27; i++) {
    if (freq2[i] != 0) {
      temp = freq[i] / freq2[i];
      if (temp < fact2) fact2 = temp;
    }
  }
  if (fact1 == INT_MAX) fact1 = 0;
  if (fact2 == INT_MAX) fact2 = 0;
  suba = fact1 + fact2;
  for (i = 0; i < 27; i++) {
    if (freq2[i] != 0) {
      freq[i] = freq[i] - freq2[i] * fact2;
    }
  }
  int fact3 = INT_MAX;
  int fact4 = INT_MAX;
  for (i = 0; i < 27; i++) {
    if (freq2[i] != 0) {
      temp = freq3[i] / freq2[i];
      if (temp < fact3) fact3 = temp;
    }
  }
  int suba1;
  for (i = 0; i < 27; i++) {
    if (freq2[i] != 0) {
      freq3[i] = freq3[i] - freq2[i] * fact3;
    }
  }
  for (i = 0; i < 27; i++) {
    if (freq1[i] != 0) {
      temp = freq3[i] / freq1[i];
      if (temp < fact4) fact4 = temp;
    }
  }
  if (fact3 == INT_MAX) fact3 = 0;
  if (fact4 == INT_MAX) fact4 = 0;
  suba1 = fact3 + fact4;
  for (i = 0; i < 27; i++) {
    if (freq1[i] != 0) {
      freq3[i] = freq3[i] - freq1[i] * fact4;
    }
  }
  if (suba >= suba1) {
    int t = 0;
    for (i = 0; i < fact1; i++) {
      for (j = 0; j < str1.length(); j++) {
        arr[t] = str1[j];
        t++;
      }
    }
    for (i = 0; i < fact2; i++) {
      for (j = 0; j < str2.length(); j++) {
        arr[t] = str2[j];
        t++;
      }
    }
    for (i = 0; i < 27; i++) {
      while (freq[i] != 0) {
        arr[t] = i + 'a';
        freq[i]--;
        t++;
      }
    }
    arr[t] = '\0';
  } else {
    int t = 0;
    for (i = 0; i < fact3; i++) {
      for (j = 0; j < str2.length(); j++) {
        arr[t] = str2[j];
        t++;
      }
    }
    for (i = 0; i < fact4; i++) {
      for (j = 0; j < str1.length(); j++) {
        arr[t] = str1[j];
        t++;
      }
    }
    for (i = 0; i < 27; i++) {
      while (freq3[i] != 0) {
        arr[t] = i + 'a';
        freq3[i]--;
        t++;
      }
    }
    arr[t] = '\0';
  }
  cout << arr << endl;
  return 0;
}
