#include <bits/stdc++.h>
using namespace std;
void f(map<char, int>& m, string& s) {
  for (int i = 0; i < s.size(); i++) m[s[i]]++;
}
int main() {
  ios::sync_with_stdio(false);
  string a, b, c;
  cin >> a >> b >> c;
  map<char, int> x, y, z;
  f(x, a);
  f(y, b);
  f(z, c);
  int total = a.size();
  for (auto p : y) total = min(total, x[p.first] / p.second);
  int ans1 = total, ans2 = 0;
  for (int i = total; i >= 0; i--) {
    int tmp = a.size();
    for (auto p : z) tmp = min(tmp, (x[p.first] - y[p.first] * i) / p.second);
    if (i + tmp > ans1 + ans2) {
      ans1 = i;
      ans2 = tmp;
    }
  }
  for (int i = 0; i < ans1; i++) cout << b;
  for (int i = 0; i < ans2; i++) cout << c;
  for (auto p : x)
    for (int j = ans1 * y[p.first] + ans2 * z[p.first]; j < p.second; j++)
      cout << p.first;
  cout << '\n';
  return 0;
}
