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

#pragma region headers/definitions
//Author: Romanov Artem
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#pragma region headers
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma endregion
using namespace std;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef long long int64;
typedef unsigned long long uint64;
typedef long double dbl;
#define EPS 1e-12
#define D_INF HUGE_VAL
#define D_NINF (-HUGE_VAL)
#define T_MAX(T) numeric_limits<T>::max()
#define T_MIN(T) numeric_limits<T>::min()
#define _IT ::iterator
#define _RIT ::reverse_iterator
#define _PT ::pointer
#define m_p make_pair
#pragma endregion
//#define IN "input.txt"
//#define OUT "output.txt"

string s, s1, s2,ans1="",ans2="";
map< char, int> m, m1, m2;
int k1, k2, n,x1=0,x2=0;

void init() {
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        m[s[i]]++;
    }
    cin >> s1;
    for (int i = 0; i < s1.size(); i++)
    {
        m1[s1[i]]++;
    }
    cin >> s2;
    for (int i = 0; i < s2.size(); i++)
    {
        m2[s2[i]]++;
    }
    k1 = T_MAX(int);
    for (auto it = m1.begin(); it != m1.end(); it++)
    {
        k1 = min(k1, m[it->first] / it->second);
    }
    k2 = T_MAX(int);
    for (auto it = m2.begin(); it != m2.end(); it++)
    {
        k2 = min(k2, m[it->first] / it->second);
    }
    n = s.size();
    if (max(k1, k2) != 0)
    {
        for (int i = 0; i < k1; i++)
        {
            ans1+=s1;
            x1++;
            for (auto it = m1.begin(); it != m1.end(); it++)
            {
                m[it->first] -= it->second;
            }
        }
        k2 = T_MAX(int);
        for (auto it = m2.begin(); it != m2.end(); it++)
        {
            k2 = min(k2, m[it->first] / it->second);
        }
        for (int i = 0; i < k2; i++)
        {
            ans1+=s2;
            x1++;
            for (auto it = m2.begin(); it != m2.end(); it++)
            {
                m[it->first] -= it->second;
            }
        }
        for (auto it = m.begin(); it != m.end(); it++)
        {
            for (int i = 0; i < it->second; i++)
            {
                ans1+=it->first;
            }
        }
    }
    else
    {
        cout << s;
        return;
    }
    m.clear();
    m1.clear();
    m2.clear();
    for (int i = 0; i < s.size(); i++)
    {
        m[s[i]]++;
    }
    for (int i = 0; i < s1.size(); i++)
    {
        m1[s1[i]]++;
    }
    for (int i = 0; i < s2.size(); i++)
    {
        m2[s2[i]]++;
    }
    k1 = T_MAX(int);
    for (auto it = m1.begin(); it != m1.end(); it++)
    {
        k1 = min(k1, m[it->first] / it->second);
    }
    k2 = T_MAX(int);
    for (auto it = m2.begin(); it != m2.end(); it++)
    {
        k2 = min(k2, m[it->first] / it->second);
    }
    n = s.size();
    if (max(k1, k2) != 0)
    {
        for (int i = 0; i < k2; i++)
        {
            ans2+=s2;
            x2++;
            for (auto it = m2.begin(); it != m2.end(); it++)
            {
                m[it->first] -= it->second;
            }
        }
        k1 = T_MAX(int);
        for (auto it = m1.begin(); it != m1.end(); it++)
        {
            k1 = min(k1, m[it->first] / it->second);
        }
        for (int i = 0; i < k1; i++)
        {
            ans2+=s1;
            x2++;
            for (auto it = m1.begin(); it != m1.end(); it++)
            {
                m[it->first] -= it->second;
            }
        }
        for (auto it = m.begin(); it != m.end(); it++)
        {
            for (int i = 0; i < it->second; i++)
            {
                ans2+=it->first;
            }
        }
    }
    if (x1>=x2){cout << ans1;}else {cout << ans2;}
}

void build() {

}

void update() {

}

void solve() {

}

void printAns() {

}

int main() {
#pragma region I/O
    ios_base::sync_with_stdio(false);
#ifdef _DEBUG
    uint TEST_NUM = 0;
    freopen("input.txt", "r", stdin);
#define EOS !cin.eof()
#define P_DEBUG printf("\n           TEST %3d           \n-----////////////////////-----\n\n", ++TEST_NUM)
#else
#define EOS false
#define P_DEBUG
#ifdef IN
    freopen(IN, "r", stdin);
#endif
#ifdef OUT
    freopen(OUT, "w", stdout);
#endif
#endif
    cout.setf(ios::fixed);
    cout.precision(11);
#pragma endregion
    do {
        P_DEBUG;
        init();
        solve();
        printAns();
    } while (EOS);
    return 0;
}
