#include<iostream>
using namespace std;
string str;
int main(){
int a,max=-1,min=101,sum;
for(int i=0;i<3;i++){
cin>>a;
if(max<a){
max=a;
}
if(min>a){
min=a;
}
sum+=a;
}
sum=sum-min-max;
cin>>str;
if(str[0]=='A'){
if(str[1]=='B'){
cout<<min<<" "<<sum<<" "<<max;
}else{
cout<<min<<" "<<max<<" "<<sum;
}
}else if(str[0]=='B'){
if(str[1]=='A'){
cout<<sum<<" "<<min<<" "<<max;
}else{
cout<<sum<<" "<<max<<" "<<min;
}
}else if(str[0]=='C'){
if(str[1]=='A'){
cout<<max<<" "<<min<<" "<<sum;
}else{
cout<<max<<" "<<sum<<" "<<max;
}
}
return 0;
}