import java.util.*;
public class main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNextLine())
{
String str1 = sc.nextLine().toLowerCase();
String str2 = sc.nextLine().toLowerCase();
int[] count1 = new int[26];
int[] count2 = new int[26];
for(int i = 0; i < str1.length(); i++)
{
char c = str1.charAt(i);
if(c>='a' && c <= 'z')
count1[c - 'a']++;
}
for(int i = 0; i < str2.length(); i++)
{
char c = str2.charAt(i);
if(c >= 'a' && c <= 'z')
count2[c - 'a']++;
}
for(int i = 0; i < 26; i++)
if(count1[i] != 0 && count2[i] != 0)
{
int min = Math.min(count1[i], count2[i]);
for(int j = 0; j < min; j++)
System.out.print((char)(i + 'a'));
}
System.out.println();
}
}
};
留言
張貼留言