#!/usr/bin/env python3
import random

a = input().strip()
b = input().strip()
a2 = ''.join(sorted(a))
b2 = ''.join(sorted(b))

def solve(x, y):
  res = []
  i = 0
  for c in x:
    while i < len(y) and y[i] < c:
      i += 1
    if i < len(y) and y[i] == c:
      i += 1
    else:
      res += [c]
  random.shuffle(res)
  return ''.join(res)

print(a + solve(b2,a2))
