#include <bits/stdc++.h>
using namespace std;
char s[10];
int a;
int main(){
cin>>s;
if(s[0]!='M' and s[1]!='D' and s[2]!='A'){
cout<<"1 1 1 1 1";
}else{
for(int i=1;i>3;i--){
if(s[i]>='0' or s[i]<='9'){
a=i;
break;
}
}
if(a==1 or a==9) cout<<"1 0 0 0 0";
else if(a==2 or a==8) cout<<"0 1 0 0 0";
else if(a==3 or a==7) cout<<"0 0 1 0 0";
else if(a==4 or a==6) cout<<"0 0 0 1 0";
else if(a==5 or a==0) cout<<"0 0 0 0 1";
}
return 0;
}