import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
String now=in.next();
String del=in.next();
now=now.replace(del,"");
System.out.println(now);
reverse(now);
}
private static void reverse(String str) {
if(str.length()==1) {
System.out.println(str);
}
else {
String s1=str.substring(0,str.length()-1);
String s2=str.substring(str.length()-1);
System.out.print(s2);
reverse(s1);
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
String a;
Scanner in=new Scanner(System.in);
a=in.next();
ArrayList<String>b=new ArrayList<String>();
while(!a.equals("end")) {
b.add(a);
a=in.next();
}
Collections.sort(b);
for(int i=0;i<b.size();i++) {
System.out.print(b.get(i)+" ");
}
}