#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-9;
string::iterator it;
vector<int> mas;
bool my(char a, char b) { return (a - '0') > (b - '0'); }
int main() {
  string a, b;
  cin >> a >> b;
  sort(b.begin(), b.end(), my);
  int k = 0;
  for (int i = 0; i < a.length(); i++) {
    if (k >= b.length()) break;
    if ((a[i] - '0') < (b[k] - '0')) {
      a[i] = b[k];
      k++;
    }
  }
  while (a[0] == '0') {
    a.erase(a.begin());
  }
  if (a.length() == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << a << endl;
  return 0;
}
