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() {
  int l1, l2, i, j, x = 0, k = 0, y1 = 0, y2 = 0;
  bool t;
  char a[1000001], b[100001], c[100001], d[100001];
  char m;
  cin.getline(a, 100001);
  for (i = 0; a[i] != '\0'; i++) {
    d[i] = a[i];
  }
  cin.getline(b, 100001);
  cin.getline(c, 100001);
  while (a[k] != '\0') {
    for (i = 0; c[i] != '\0'; i++) {
      t = 0;
      for (j = k; a[j] != '\0'; j++) {
        if (a[j] == c[i]) {
          m = a[j];
          a[j] = a[k];
          a[k] = m;
          k++;
          if (c[i + 1] == '\0') {
            x = k;
            y1++;
          }
          t = 1;
          break;
        }
      }
      if (t == 0) {
        break;
      }
    }
    if (t == 0) {
      break;
    }
  }
  if (a[k] != '\0') {
    k = x;
  }
  while (a[k] != '\0') {
    bool t;
    for (i = 0; b[i] != '\0'; i++) {
      t = 0;
      for (j = k; a[j] != '\0'; j++) {
        if (a[j] == b[i]) {
          m = a[j];
          a[j] = a[k];
          a[k] = m;
          k++;
          if (c[i + 1] == '\0') {
            x = k;
            y1++;
          }
          t = 1;
          break;
        }
      }
      if (t == 0) {
        break;
      }
    }
    if (t == 0) {
      break;
    }
  }
  x = k = 0;
  while (d[k] != '\0') {
    for (i = 0; b[i] != '\0'; i++) {
      t = 0;
      for (j = k; d[j] != '\0'; j++) {
        if (d[j] == b[i]) {
          m = d[j];
          d[j] = d[k];
          d[k] = m;
          k++;
          if (b[i + 1] == '\0') {
            x = k;
            y2++;
          }
          t = 1;
          break;
        }
      }
      if (!t) {
        break;
      }
    }
    if (t == 0) {
      break;
    }
  }
  if (d[k] != '\0') {
    k = x;
  }
  while (d[k] != '\0') {
    bool t;
    for (i = 0; c[i] != '\0'; i++) {
      t = 0;
      for (j = k; d[j] != '\0'; j++) {
        if (d[j] == c[i]) {
          m = d[j];
          d[j] = d[k];
          d[k] = m;
          k++;
          if (c[i + 1] == '\0') {
            x = k;
            y2++;
          }
          t = 1;
          break;
        }
      }
      if (t == 0) {
        break;
      }
    }
    if (t == 0) {
      break;
    }
  }
  if (y1 > y2) {
    cout << a;
  } else {
    cout << d;
  }
}
