#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 10;
const long long INF = 4e18 + 10;
const int maxn = 1 * 1e5 + 5;
const int maxe = maxn;
char a[maxn], b[maxn], c[maxn];
int cnt[300];
int need[2][300];
int MAIN() {
  scanf("%s%s%s", a, b, c);
  for (int i = 0; a[i]; ++i) ++cnt[a[i]];
  for (int i = 0; b[i]; ++i) need[0][b[i]]++;
  for (int i = 0; c[i]; ++i) need[1][c[i]]++;
  int bmx = inf;
  for (int i = 0; i < 300; ++i) {
    if (!need[0][i]) continue;
    bmx = min(bmx, cnt[i] / need[0][i]);
  }
  int mx = -1, rb, rc;
  for (int bcnt = 0; bcnt <= bmx; ++bcnt) {
    int ccnt = inf;
    for (int i = 0; i < 300; ++i) {
      if (!need[1][i]) continue;
      int res = cnt[i] - bcnt * need[0][i];
      if (res < need[1][i]) {
        ccnt = 0;
        break;
      } else {
        ccnt = min(ccnt, res / need[1][i]);
      }
    }
    if (bcnt + ccnt > mx) {
      mx = bcnt + ccnt;
      rb = bcnt, rc = ccnt;
    }
  }
  for (int i = 0; i < rb; ++i) {
    for (int j = 0; b[j]; ++j) {
      putchar(b[j]);
      --cnt[b[j]];
    }
  }
  for (int i = 0; i < rc; ++i) {
    for (int j = 0; c[j]; ++j) {
      putchar(c[j]);
      --cnt[c[j]];
    }
  }
  for (int i = 0; i < 300; ++i)
    while (cnt[i]--) putchar(i);
  puts("");
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  int ret = MAIN();
  return ret;
}
