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;
unordered_map<string, bool> s;
unordered_map<long long int, long long int> po;
int main() {
  string s;
  cin >> s;
  int a[26] = {0};
  int d = s.length();
  for (int i = 0; i < d; i++) {
    int k = s[i] - 'a';
    a[k]++;
  }
  string t, r;
  cin >> t >> r;
  int y = t.length();
  int h = r.length();
  if (y > h) {
    string l = r;
    r = t;
    t = l;
  }
  int b[26] = {0};
  int c[26] = {0};
  y = t.length();
  h = r.length();
  for (int i = 0; i < y; i++) {
    int k = t[i] - 'a';
    b[k]++;
  }
  for (int i = 0; i < h; i++) {
    int k = r[i] - 'a';
    c[k]++;
  }
  int p = 10000000;
  for (int i = 0; i < 26; i++) {
    if (b[i] != 0) {
      p = min(p, (a[i] / b[i]));
    }
  }
  int o = 1000000;
  for (int i = 0; i < 26; i++) {
    if (c[i] != 0) {
      o = min(o, (a[i] / c[i]));
    }
  }
  int f = 10000000;
  for (int i = 0; i < 26; i++) {
    if (c[i] != 0) {
      f = min(f, ((a[i] - (b[i] * p)) / c[i]));
    }
  }
  int x = 10000000;
  for (int i = 0; i < 26; i++) {
    if (b[i] != 0) {
      x = min(x, (a[i] - (c[i] * o) / b[i]));
    }
  }
  if (p == 0 && o == 0) {
    cout << s;
    return 0;
  }
  if (p + f >= x + o) {
    for (int i = 0; i < 26; i++) {
      if (a[i] != 0) {
        a[i] -= (c[i] * f);
        a[i] -= (b[i] * p);
      }
    }
    for (int i = 0; i < p; i++) {
      cout << t;
    }
    for (int i = 0; i < 26; i++) {
      for (int j = 0; j < a[i]; j++) {
        cout << char(i + 97);
      }
    }
    for (int i = 0; i < f; i++) {
      cout << r;
    }
  } else {
    for (int i = 0; i < 26; i++) {
      if (a[i] != 0) {
        a[i] -= (c[i] * o);
        a[i] -= (b[i] * x);
      }
    }
    for (int i = 0; i < x; i++) {
      cout << t;
    }
    for (int i = 0; i < 26; i++) {
      for (int j = 0; j < a[i]; j++) {
        cout << char(i + 97);
      }
    }
    for (int i = 0; i < o; i++) {
      cout << r;
    }
  }
  return 0;
}
