#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
int n, m, k, A[30], B[30], AB[30];
int d, res, fst, sec;
char s[N], a[N], b[N], ans[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++) AB[s[i] - 'a']++;
  for (int i = 1; i <= m; i++) A[a[i] - 'a']++;
  for (int i = 1; i <= k; i++) B[b[i] - 'a']++;
  for (int i = 0;; i++) {
    int x = n;
    for (int j = 0; j < 26; j++)
      if (B[j]) x = min(x, AB[j] / B[j]);
    if (x + i > res) {
      res = x + i;
      fst = i;
      sec = x;
    }
    bool f = false;
    for (int j = 0; j < 26; j++)
      if (AB[j] < A[j]) {
        f = true;
        break;
      } else
        AB[j] -= A[j];
    if (f) break;
  }
  for (int i = 1; i <= fst; i++)
    for (int j = 1; j <= m; j++) d++, ans[d] = a[j];
  for (int i = 1; i <= sec; i++)
    for (int j = 1; j <= k; j++) d++, ans[d] = b[j];
  for (int i = 0; i < 26; i++) AB[i] = -A[i] * fst - B[i] * sec;
  for (int i = 1; i <= n; i++) AB[s[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    for (int j = 1; j <= AB[i]; j++) ans[++d] = 'a' + i;
  for (int i = 1; i <= n; i++) printf("%c", ans[i]);
  return 0;
}
