#include <bits/stdc++.h>
#pragma comment(linker, "/stack:336777216")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using vec3 = array<T, 3>;
template <typename T>
using vec2 = array<T, 2>;
template <typename T, size_t _bits>
using mat2d = array<array<T, _bits>, _bits>;
inline namespace mylovelytemplate {
ostream &operator<<(ostream &os, const stringstream &ss) {
  os << ss.str();
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (auto it = d.begin(); it != d.end(); it++) {
    os << *it << " ";
  }
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " , " << p.second;
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size(); i++) {
    os << v[i] << " ";
  }
  return os;
}
template <typename T, size_t x>
ostream &operator<<(ostream &os, const array<T, x> &v) {
  for (auto it = v.begin(); it != v.end(); it++) {
    os << *it << " ";
  }
  return os;
}
struct comp {
  bool strbylength(const string &a, const string &b) {
    return a.size() < b.size();
  }
  template <typename T1, typename T2>
  bool pairbysecond(const pair<T1, T2> &first, const pair<T1, T2> &second) {
    if (first.second != second.second) return first.second < second.second;
    return first.first < second.first;
  }
};
struct hashing {
  size_t operator()(pair<int, int> p) const {
    return std::hash<size_t>()((size_t(p.first) << 32) + p.second);
  }
};
template <typename T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <typename T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <typename T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
class DSU {
 public:
  int cnt, max_size;
  vector<int> parent, size;
  stack<pair<pair<int, int>, pair<int, int>>> history;
  DSU(int N) {
    cnt = N;
    parent = vector<int>(N);
    size = vector<int>(N, 1);
    max_size = 1;
    for (int i = 0; i < N; i++) parent[i] = i;
  }
  int find(int p) {
    int root = p;
    while (root != parent[root]) root = parent[root];
    while (p != root) {
      int newp = parent[p];
      parent[p] = root;
      p = newp;
    }
    return root;
  }
  int find_r(int p) {
    int root = p;
    while (root != parent[root]) root = parent[root];
    return root;
  }
  void merge(int x, int y) {
    int i = find(x);
    int j = find(y);
    if (i == j) return;
    if (size[i] < size[j]) {
      parent[i] = j, size[j] += size[i];
      max_size = max(max_size, size[j]);
    } else {
      parent[j] = i, size[i] += size[j];
      max_size = max(max_size, size[i]);
    }
    cnt--;
  }
  void merge_r(int x, int y) {
    int i = find_r(x);
    int j = find_r(y);
    if (i == j) return;
    history.push({{i, parent[i]}, {j, size[j]}});
    parent[i] = j;
    size[j] += size[i];
    max_size = max(max_size, size[j]);
    cnt--;
  }
  void revert() {
    while (!history.empty()) {
      parent[history.top().first.first] = history.top().first.second;
      size[history.top().second.first] = history.top().second.second;
      history.pop();
    }
  }
  bool connected(int x, int y) { return find(x) == find(y); }
};
template <typename T>
T totient(T x) {
  T result = x;
  for (int i = 0; i * i <= x; i++) {
    if (x % i == 0) {
      while (x % i == 0) {
        x /= i;
      }
      result -= result / i;
    }
  }
  if (x > 1) {
    result -= result / x;
  }
  return result;
}
template <typename T>
T gcd(T a, T b) {
  while (b != 0) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <typename T>
T binaryexpo(T base, T exp, const T mod) {
  T ans = 1;
  base = base % mod;
  while (exp > 0) {
    if (exp & 1) {
      ans = (ans * base) % mod;
    }
    exp >>= 1;
    base = (base * base) % mod;
  }
  return ans % mod;
}
template <typename T>
T binaryexpo(T base, const T exp) {
  T ans = 1;
  while (exp > 0) {
    if (exp & 1) {
      ans *= base;
    }
    exp >>= 1;
    base *= base;
  }
  return ans;
}
template <typename T>
T getdistance3dpointtoline(vec3<T> &A, vec3<T> &B, vec3<T> &C) {
  vec3<T> BA, BC;
  for (int i = 0; i < 3; i++) {
    BA[i] = A[i] - B[i];
    BC[i] = C[i] - B[i];
  }
  vec3<T> BAXBC;
  BAXBC[0] = BA[1] * BC[2] - BA[2] * BC[1];
  BAXBC[1] = BA[2] * BC[0] - BA[0] * BC[2];
  BAXBC[2] = BA[0] * BC[1] - BA[1] * BC[0];
  T modUP = 0.0, modDOWN = 0.0;
  for (int i = 0; i < 3; i++) {
    modUP += BAXBC[i] * BAXBC[i];
    modDOWN += BC[i] * BC[i];
  }
  T distance = modUP / modDOWN;
  return distance;
}
template <typename T, size_t _bits>
mat2d<T, _bits> matmul(mat2d<T, _bits> &A, mat2d<T, _bits> &B) {
  mat2d<T, _bits> C;
  for (int i = 0; i < _bits; i++) {
    for (int j = 0; j < _bits; j++) {
      C[i][j] = 0;
      for (int k = 0; k < _bits; k++) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
  return C;
}
template <typename T, size_t _bits>
mat2d<T, _bits> matmul(mat2d<T, _bits> &A, mat2d<T, _bits> &B, const T M) {
  mat2d<T, _bits> C;
  for (int i = 0; i < _bits; i++) {
    for (int j = 0; j < _bits; j++) {
      C[i][j] = 0;
      for (int k = 0; k < _bits; k++) {
        C[i][j] += (A[i][k] * B[k][j]) % M;
      }
      C[i][j] %= M;
    }
  }
  return C;
}
template <typename T, size_t _bits>
mat2d<T, _bits> matrixexpo(mat2d<T, _bits> &X, ll n) {
  mat2d<T, _bits> C = {};
  for (int i = 0; i < _bits; i++) C[i][i] = 1;
  while (n > 0) {
    if (n & 1) C = matmul(C, X);
    n >>= 1;
    X = matmul(X, X);
  }
  return C;
}
template <typename T, size_t _bits>
mat2d<T, _bits> matrixexpo(mat2d<T, _bits> &X, ll n, const T M) {
  mat2d<T, _bits> C = {};
  for (int i = 0; i < _bits; i++) C[i][i] = 1;
  while (n > 0) {
    if (n & 1) C = matmul(C, X, M);
    n >>= 1;
    X = matmul(X, X, M);
  }
  return C;
}
}  // namespace mylovelytemplate
string a, b, c;
unordered_map<char, int> fa, fb, fc;
int numbb() {
  int ma = 1e9;
  for (auto it = fb.begin(); it != fb.end(); it++) {
    if (fa.find(it->first) == fa.end()) {
      ma = 0;
      break;
    }
    int pos = fa[it->first] / it->second;
    ma = min(ma, pos);
  }
  return ma;
}
void useb(int times) {
  for (auto it = fb.begin(); it != fb.end(); it++) {
    fa[it->first] -= (times * it->second);
  }
}
void usec(int times) {
  for (auto it = fc.begin(); it != fc.end(); it++) {
    fa[it->first] -= (times * it->second);
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> a >> b >> c;
  for (int i = 0; i < a.size(); i++) {
    fa[a[i]]++;
  }
  for (int i = 0; i < b.size(); i++) {
    fb[b[i]]++;
  }
  for (int i = 0; i < c.size(); i++) {
    fc[c[i]]++;
  }
  int bestb = 0, bestc = 0;
  int numb = numbb();
  for (int i = 0; i <= numb; i++) {
    int numc = 1e9;
    for (auto it = fc.begin(); it != fc.end(); it++) {
      numc = min(numc, (fa[it->first] - fb[it->first] * i) / it->second);
    }
    if (i + numc > bestc + bestb) {
      bestb = i;
      bestc = numc;
    }
  }
  for (int i = 0; i < bestb; i++) cout << b;
  for (int i = 0; i < bestc; i++) cout << c;
  useb(bestb);
  usec(bestc);
  for (auto it = fa.begin(); it != fa.end(); it++) {
    for (int i = 0; i < it->second; i++) {
      cout << it->first;
    }
  }
  cout << "\n";
  return 0;
}
