#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
int n, m, k, ba[26], bb[26], bs[26];
int d, res, prvi, drugi;
char s[N], a[N], b[N], resenje[N];
int main()
{
scanf("%s %s %s", s + 1, a + 1, b + 1);
n = strlen(s + 1);
m = strlen(a + 1);
k = strlen(b + 1);
for (int i = 1; i <= n; i++) bs[s[i] - 'a']++;
for (int i = 1; i <= m; i++) ba[a[i] - 'a']++;
for (int i = 1; i <= k; i++) bb[b[i] - 'a']++;
for (int i = 0; ; i++)
{
int x = n;
for (int j = 0; j < 26; j++) if (bb[j]) x = min(x, bs[j] / bb[j]);
if (x + i > res)
{
res = x + i;
prvi = i;
drugi = x;
}
bool f = false;
for (int j = 0; j < 26; j++) if (bs[j] < ba[j])
{
f = true;
break;
} else
bs[j] -= ba[j];
if (f) break;
}
for (int i = 1; i <= prvi; i++)
for (int j = 1; j <= m; j++) resenje[++d] = a[j];
for (int i = 1; i <= drugi; i++)
for (int j = 1; j <= k; j++) resenje[++d] = b[j];
for (int i = 0; i < 26; i++) bs[i] = -ba[i] * prvi - bb[i] * drugi;
for (int i = 1; i <= n; i++) bs[s[i] - 'a']++;
for (int i = 0; i < 26; i++)
for (int j = 1; j <= bs[i]; j++) resenje[++d] = 'a' + i;
for (int i = 1; i <= n; i++) printf("%c", resenje[i]);
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxhbGdvcml0aG0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE4gPSAxMDAwMTA7CmludCBuLCBtLCBrLCBiYVsyNl0sIGJiWzI2XSwgYnNbMjZdOwppbnQgZCwgcmVzLCBwcnZpLCBkcnVnaTsKY2hhciBzW05dLCBhW05dLCBiW05dLCByZXNlbmplW05dOwoKaW50IG1haW4oKQp7CiAgICBzY2FuZigiJXMgJXMgJXMiLCBzICsgMSwgYSArIDEsIGIgKyAxKTsKICAgIG4gPSBzdHJsZW4ocyArIDEpOwogICAgbSA9IHN0cmxlbihhICsgMSk7CiAgICBrID0gc3RybGVuKGIgKyAxKTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgYnNbc1tpXSAtICdhJ10rKzsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG07IGkrKykgYmFbYVtpXSAtICdhJ10rKzsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IGs7IGkrKykgYmJbYltpXSAtICdhJ10rKzsKICAgIGZvciAoaW50IGkgPSAwOyA7IGkrKykKICAgIHsKICAgICAgICBpbnQgeCA9IG47CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCAyNjsgaisrKSBpZiAoYmJbal0pIHggPSBtaW4oeCwgYnNbal0gLyBiYltqXSk7CiAgICAgICAgaWYgKHggKyBpID4gcmVzKQogICAgICAgIHsKICAgICAgICAgICAgcmVzID0geCArIGk7CiAgICAgICAgICAgIHBydmkgPSBpOwogICAgICAgICAgICBkcnVnaSA9IHg7CiAgICAgICAgfQogICAgICAgIGJvb2wgZiA9IGZhbHNlOwogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgMjY7IGorKykgaWYgKGJzW2pdIDwgYmFbal0pCiAgICAgICAgewogICAgICAgICAgICBmID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfSBlbHNlCiAgICAgICAgYnNbal0gLT0gYmFbal07CiAgICAgICAgaWYgKGYpIGJyZWFrOwogICAgfQogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gcHJ2aTsgaSsrKQogICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG07IGorKykgcmVzZW5qZVsrK2RdID0gYVtqXTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IGRydWdpOyBpKyspCiAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPD0gazsgaisrKSByZXNlbmplWysrZF0gPSBiW2pdOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCAyNjsgaSsrKSBic1tpXSA9IC1iYVtpXSAqIHBydmkgLSBiYltpXSAqIGRydWdpOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSBic1tzW2ldIC0gJ2EnXSsrOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCAyNjsgaSsrKQogICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IGJzW2ldOyBqKyspIHJlc2VuamVbKytkXSA9ICdhJyArIGk7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHByaW50ZigiJWMiLCByZXNlbmplW2ldKTsKICAgIHJldHVybiAwOwp9Cg==