#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
inline long long expo(long long base, int nent) {
  if (nent == 1)
    return base;
  else if (nent & 1) {
    long long temp = expo(base, nent / 2);
    temp = (temp * temp) % MOD * base;
    if (temp >= MOD) temp %= MOD;
    return temp;
  } else {
    long long temp = expo(base, nent / 2);
    temp *= temp;
    if (temp >= MOD) temp %= MOD;
    return temp;
  }
}
int hs[26], ha[26], hb[26], c[26], m1 = MOD, m2 = MOD, ans, temp, a1, a2, prev;
bool f;
int main() {
  string s, a, b, res;
  cin >> s >> a >> b;
  for (int i = 0; i < (int)s.length(); i++) hs[s[i] - 97]++;
  for (int i = 0; i < (int)a.length(); i++) ha[a[i] - 97]++;
  for (int i = 0; i < (int)b.length(); i++) hb[b[i] - 97]++;
  for (int i = 0; i < (int)26; i++)
    if (ha[i]) m1 = min(hs[i] / ha[i], m1);
  for (int i = 0; i < (int)26; i++)
    if (hb[i]) m2 = min(hs[i] / hb[i], m2);
  for (int i = 0; i < (int)26; i++)
    if (ha[i] != hb[i]) {
      f = 1;
      break;
    }
  if (m1 && m2 && f) {
    f = 0;
    if (m1 > m2)
      ans = a1 = m1;
    else
      ans = a2 = m2;
    temp = m2;
    for (int j = 0; j < (int)26; j++) c[j] = hs[j];
    for (int i = 1; i < (int)m1 + 1; i++) {
      if (f) break;
      for (int j = 0; j < (int)26; j++) c[j] -= ha[j];
      for (int j = temp; j >= 0; j--) {
        if (!j) {
          f = 1;
          break;
        }
        f = 0;
        for (int k = 0; k < (int)26; k++)
          if (c[k] - j * hb[k] < 0) {
            f = 1;
            break;
          }
        if (!f) {
          temp = j;
          if (i + j > ans) ans = i + j, a1 = i, a2 = j;
          break;
        }
      }
    }
  } else if (!f)
    ans = a1 = m1;
  else if (m1)
    ans = a1 = m1;
  else
    ans = a2 = m2;
  res = "";
  for (int i = 0; i < (int)a1; i++) res += a;
  for (int i = 0; i < (int)a2; i++) res += b;
  for (int i = 0; i < (int)26; i++) hs[i] -= (a1 * ha[i] + a2 * hb[i]);
  for (int i = 0; i < (int)26; i++)
    for (int j = 0; j < (int)hs[i]; j++) res += (char)(97 + i);
  cout << res;
  return 0;
}
