#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  string a, b, c;
  cin >> a >> b >> c;
  vector<int> va(26), vb(26), vc(26);
  for (char x : a) va[x - 'a']++;
  for (char x : b) vb[x - 'a']++;
  for (char x : c) vc[x - 'a']++;
  int maxsum = 0, maxi = 0, maxj = 0;
  bool stop = false;
  for (int i = 0; i <= a.size() && !stop; ++i) {
    int j = a.size();
    for (int x = 0; x < 26; ++x) {
      if (vc[x]) j = min(j, va[x] / vc[x]);
    }
    if (maxsum < i + j) {
      maxsum = i + j;
      maxi = i;
      maxj = j;
    }
    for (int x = 0; x < 26; ++x) {
      if (va[x] < vb[x]) {
        stop = true;
        break;
      }
      va[x] -= vb[x];
    }
  }
  string ans;
  for (int i = 0; i < maxi; ++i) ans += b;
  for (int j = 0; j < maxj; ++j) ans += c;
  va.assign(va.size(), 0);
  for (char x : a) va[x - 'a']++;
  for (int x = 0; x < 26; ++x) {
    va[x] -= maxi * vb[x] + maxj * vc[x];
    for (int k = 0; k < va[x]; ++k) ans += (char)(x + 'a');
  }
  cout << ans << "\n";
  return 0;
}
