#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum = 1e9, cnt, k1 = 0, k2 = 0, i;
  string a, b, c;
  map<char, int> ma, mb, mc;
  cin >> a >> b >> c;
  for (char ch : a) ++ma[ch];
  for (char ch : b) ++mb[ch];
  for (char ch : c) ++mc[ch];
  for (auto it : mb) sum = min(sum, ma[it.first] / it.second);
  for (i = 0; i <= sum; ++i) {
    cnt = 1e9;
    for (auto it : mc)
      cnt = min(cnt, (ma[it.first] - mb[it.first] * i) / it.second);
    if (cnt + i > k1 + k2) k1 = i, k2 = cnt;
  }
  for (i = 0; i < k1; ++i) cout << b;
  for (i = 0; i < k2; ++i) cout << c;
  for (auto it : ma) {
    it.second -= mb[it.first] * k1 + mc[it.first] * k2;
    for (i = 0; i < it.second; ++i) cout << it.first;
  }
  cout << endl;
  return 0;
}
