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;
class CharacterCounter {
 private:
  const int oo;
  vector<int> arr;

 public:
  CharacterCounter() : oo(0x7fffffff) { arr.assign(26, 0); }
  CharacterCounter(const CharacterCounter& other) : oo(0x7fffffff) {
    arr = other.arr;
  }
  CharacterCounter& operator=(const CharacterCounter& other) {
    if (this != &other) {
      arr = other.arr;
    }
    return (*this);
  }
  CharacterCounter(const string& s) : oo(0x7fffffff) {
    arr.assign(26, 0);
    for (int i = 0; i < s.length(); i++) (*this)[s[i]]++;
  }
  int& operator[](size_t index) { return arr[index - 'a']; }
  const int& operator[](size_t index) const { return arr[index - 'a']; }
  int getMinPositiveCount() const {
    int minCount = oo;
    for (int i = 0; i < 26; i++)
      if (arr[i] < minCount && arr[i] > 0) minCount = arr[i];
    return (minCount == oo ? 0 : minCount);
  }
  CharacterCounter operator/(const CharacterCounter& other) const {
    CharacterCounter result;
    for (int i = 0; i < 26; i++) {
      if (other.arr[i] > 0)
        result.arr[i] = arr[i] / other.arr[i];
      else
        result.arr[i] = 0;
    }
    return result;
  }
  CharacterCounter operator%(const CharacterCounter& other) const {
    CharacterCounter temp = other * count(other);
    return (*this) - temp;
  }
  CharacterCounter operator*(const CharacterCounter& other) const {
    CharacterCounter result;
    for (int i = 0; i < 26; i++) {
      result.arr[i] = arr[i] * other.arr[i];
    }
    return result;
  }
  CharacterCounter operator*(int val) const {
    CharacterCounter result;
    for (int i = 0; i < 26; i++) {
      result.arr[i] = arr[i] * val;
    }
    return result;
  }
  CharacterCounter operator+(const CharacterCounter& other) const {
    CharacterCounter result;
    for (int i = 0; i < 26; i++) {
      result.arr[i] = arr[i] + other.arr[i];
    }
    return result;
  }
  CharacterCounter operator-(const CharacterCounter& other) const {
    CharacterCounter result;
    for (int i = 0; i < 26; i++) {
      result.arr[i] = arr[i] - other.arr[i];
    }
    return result;
  }
  bool contains(const CharacterCounter& other) const {
    for (int i = 0; i < 26; i++) {
      if (other.arr[i] > arr[i]) return false;
    }
    return true;
  }
  string toString() const {
    string result = "";
    for (int i = 0; i < 26; i++)
      for (int j = 0; j < arr[i]; j++) result += char(i + 'a');
    return result;
  }
  int count(const CharacterCounter& other) const {
    return contains(other) ? ((*this) / other).getMinPositiveCount() : 0;
  }
};
ostream& operator<<(ostream& out, const CharacterCounter& a) {
  for (int i = 'a'; i <= 'z'; i++) {
    out << char(i) << " " << a[i] << endl;
  }
  return out;
}
int main() {
  string a, b, c, result;
  cin >> a >> b >> c;
  CharacterCounter A(a), B(b), C(c);
  int bMaxCount = A.count(B);
  int cRemainder = (A % B).count(C);
  int cMaxCount = A.count(C);
  int bRemainder = (A % C).count(B);
  if (bMaxCount + cRemainder >= cMaxCount + bRemainder) {
    for (int i = 0; i < bMaxCount; i++) result += b;
    for (int i = 0; i < cRemainder; i++) result += c;
    result += (A % B % C).toString();
  } else {
    for (int i = 0; i < cMaxCount; i++) result += b;
    for (int i = 0; i < bRemainder; i++) result += c;
    result += (A % C % B).toString();
  }
  cout << result << endl;
  return 0;
}
