#include <bits/stdc++.h>
using namespace std;
template <class Iter, class T>
Iter closest_value(Iter begin, Iter end, T value) {
  Iter result = upper_bound(begin, end, value);
  if (result != begin) {
    Iter lower_result = result;
    --lower_result;
    if (result == end || ((value - *lower_result) < (*result - value))) {
      result = lower_result;
    }
  }
  return result;
}
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
set<long long int> s;
void sieve() {
  bool prime[100005 + 5];
  memset(prime, true, sizeof(prime));
  for (long long int p = 2; p * p <= 100005; p++) {
    if (prime[p] == true) {
      for (long long int i = p * 2; i <= 100005; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= 100005; p++)
    if (prime[p]) s.insert(p);
}
long long int gcd(long long int a, long long int b) {
  while (a > 0 && b > 0) {
    if (a > b) {
      a %= b;
    } else {
      b %= a;
    }
  }
  return a + b;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
bool isPerfectSquare(long long int n) {
  if (n < 0) return false;
  long long int tst = (long long int)(sqrt(n) + 0.5);
  return tst * tst == n;
}
bool ft(long long int a, long long int b, long long int c) {
  return ((a + b) > c && (b + c) > a && (a + c) > b);
}
int main() {
  string a, b;
  cin >> a >> b;
  long long int check = 0;
  map<long long int, long long int> m;
  for (long long int i = 0; i < b.length(); i++) m[b[i] - '0']++;
  for (long long int i = 0; i < a.length(); i++) {
    long long int x = a[i] - '0';
    bool f = 0;
    for (long long int i = 9; i >= 0; i--) {
      if (i > x && m[i] > 0) {
        m[i]--;
        cout << i;
        f = 1;
        check++;
        break;
      }
    }
    if (!f) {
      cout << a[i];
    }
  }
  return 0;
}
