#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c, k = "", ss, s1;
  cin >> a >> b >> c;
  bool b1 = true, b2 = true;
  ss = a;
  s1 = ss;
  int bcount = 0, ccount = 0;
  int max = 0, t = 0;
  while (b1 == true) {
    for (int i = 0; i < b.length(); i++) {
      int f = ss.find(b[i]);
      if (f == string::npos) {
        b1 = false;
        break;
      } else
        ss.erase(f, 1);
    }
    if (b1 == true) {
      bcount++;
      s1 = ss;
    } else
      ss = s1;
  }
  while (b2 == true) {
    for (int i = 0; i < c.length(); i++) {
      int f = ss.find(c[i]);
      if (f == string::npos) {
        b2 = false;
        break;
      } else
        ss.erase(f, 1);
    }
    if (b2 == true) {
      ccount++;
      s1 = ss;
    } else
      ss = s1;
  }
  t = bcount + ccount;
  max = t;
  a = ss;
  int t1 = bcount, t2 = ccount;
  while (t1 != 0) {
    b2 = true;
    s1 += b;
    ss += b;
    while (b2 == true) {
      for (int i = 0; i < c.length(); i++) {
        int f = ss.find(c[i]);
        if (f == string::npos) {
          b2 = false;
          break;
        } else
          ss.erase(f, 1);
      }
      if (b2 == true) {
        t2++;
        s1 = ss;
      } else
        ss = s1;
    }
    t1--;
    t = t1 + t2;
    if (t > max) {
      max = t;
      bcount = t1;
      ccount = t2;
      a = ss;
    }
  }
  for (int i = 0; i < bcount; i++) k += b;
  for (int i = 0; i < ccount; i++) k += c;
  sort(a.begin(), a.end());
  k += a;
  cout << k << endl;
  return 0;
}
