import java.util.*;
import java.io.*;

public class name_sp implements Runnable {
    public static void main(String[] args) {
        new Thread(new name_sp()).start();
    }

    @Override
    public void run() {
        try {
            br = new BufferedReader(new FileReader("name.in"));
            out = new PrintWriter("name.out");
            solve();
            out.close();
        } catch (FileNotFoundException e) {
        	e.printStackTrace();
        }
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    boolean eof = false;

    String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return "0";
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }

    long nextLong() {
        return Long.parseLong(nextToken());
    }
    
    int[] countLetters(char[] ch) {
    	int[] ret = new int[26];
    	for (char c : ch) {
    		ret[c - 'a']++;
    	}
    	return ret;
    }
    
    void print(char[] s1, char[] s2, int[] cnt1, int[] cnt2, int i, int j) {
    	if (i >= s1.length || j >= s2.length) return;
    	int ch = cnt1.length - 1;
    	while (ch >= 0) {
    		if (cnt1[ch] > 0 && cnt2[ch] > 0) break;
    		ch--;
    	}
    	if (ch < 0) return;
    	while (s1[i] - 'a' != ch) {
    		cnt1[s1[i++] - 'a']--;
    	}
    	while (s2[j] - 'a' != ch) {
    		cnt2[s2[j++] - 'a']--;
    	}
    	cnt1[ch]--;
    	cnt2[ch]--;
    	out.print(s1[i]);
    	print(s1, s2, cnt1, cnt2, i + 1, j + 1);
    }

    void solve() {
    	char[] s1 = nextToken().toCharArray();
    	char[] s2 = nextToken().toCharArray();
    	int[] cnt1 = countLetters(s1);
    	int[] cnt2 = countLetters(s2);
    	print(s1, s2, cnt1, cnt2, 0, 0);
    }
}
