#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const double pi = acos(-1.0);
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
const int maxn = 200005;
void task() {
  string a, b, c;
  cin >> a >> b >> c;
  std::map<int, int> A, B, C;
  for (char c : a) A[c - 'a']++;
  for (char c : b) B[c - 'a']++;
  for (char c : c) C[c - 'a']++;
  int mxB = inf, mxC = inf;
  for (int i = 0; i < 26; i++) {
    if (B[i]) mxB = min(mxB, A[i] / B[i]);
    if (C[i]) mxC = min(mxC, A[i] / C[i]);
  }
  int best = -1;
  int k1, k2;
  for (int k = 0; k < ((int)(a).size()); k++) {
    bool f = 1;
    int mn = inf;
    for (int i = 0; i < 26; i++) {
      if (B[i] * k > A[i]) {
        f = 0;
      }
    }
    if (!f) break;
    for (int i = 0; i < 26; i++) {
      if (C[i]) mn = min(mn, (A[i] - B[i] * k) / C[i]);
    }
    if (best < mn + k) best = mn + k, k1 = k, k2 = mn;
  }
  string ans;
  for (int i = 0; i < k1; i++) {
    ans += b;
  }
  for (int i = 0; i < k2; i++) {
    ans += c;
  }
  for (int i = 0; i < 26; i++) {
    A[i] -= B[i] * k1 + C[i] * k2;
    for (int j = 0; j < A[i]; j++) {
      ans += char(i + 'a');
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  while (T--) {
    task();
  }
  return 0;
}
