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;
vector<int> a(1 + 'z', 0);
void could(vector<int> a1, string s1, string s2, int &value) {
  value = (int)1e9;
  vector<int> let(1 + 'z', 0);
  for (int i = 0; i < s2.size(); i++) {
    let[s2[i]]++;
  }
  for (char c = 'a'; c <= 'z'; c++) {
    if (let[c] != 0) {
      if (a1[c] <= 0 || a1[c] / let[c] <= 0) {
        value = 0;
        return;
      }
      value = min(value, a1[c] / let[c]);
    }
  }
}
void proc(vector<int> a1, string s1, string s2, int value) {
  for (int i = 0; i < s2.size(); i++) {
    a1[s2[i]] -= value;
  }
}
void print(string s) {
  for (char c = 'a'; c <= 'z'; c++) {
    for (int i = 0; i < a[c]; i++) {
      cout << c;
    }
  }
}
int main() {
  for (char c = 'a'; c <= 'z'; c++) {
    a[c] = 0;
  }
  string s1, s2, s3;
  cin >> s1;
  cin >> s2;
  cin >> s3;
  for (int i = 0; i < s1.size(); i++) {
    a[s1[i]]++;
  }
  int value = 0;
  if (s2 == s3) {
    could(a, s1, s2, value);
    if (value == 0) {
      cout << s1;
      return 0;
    } else {
      proc(a, s1, s2, value);
      for (int i = 0; i < value; i++) {
        cout << s2;
      }
      print(s1);
    }
  } else {
    int value1 = 0;
    could(a, s1, s2, value);
    could(a, s1, s3, value1);
    if (value == 0 && value1 == 0) {
      cout << s1;
      return 0;
    } else {
      if (value == 0) {
        proc(a, s1, s3, value1);
        for (int i = 0; i < value1; i++) {
          cout << s3;
        }
      } else if (value1 == 0) {
        proc(a, s1, s2, value);
        for (int i = 0; i < value; i++) {
          cout << s2;
        }
      } else {
        vector<int> fv1 = a;
        vector<int> fv2 = a;
        proc(fv1, s1, s2, value);
        could(fv1, s1, s3, value1);
        int sum1 = value + value1;
        proc(fv2, s1, s3, value1);
        could(fv2, s1, s2, value);
        int sum2 = value + value1;
        if (sum1 > sum2) {
          proc(a, s1, s2, value);
          for (int i = 0; i < value; i++) {
            cout << s2;
          }
          could(a, s1, s3, value1);
          if (value1 > 0) {
            proc(a, s1, s3, value1);
            for (int i = 0; i < value1; i++) {
              cout << s3;
            }
          }
        } else {
          proc(a, s1, s3, value1);
          for (int i = 0; i < value1; i++) {
            cout << s3;
          }
          could(a, s1, s2, value);
          if (value > 0) {
            proc(a, s1, s2, value);
            for (int i = 0; i < value; i++) {
              cout << s2;
            }
          }
        }
      }
      print(s1);
    }
  }
  return 0;
}
