#include<iostream.h>
#include<malloc.h>
struct W{
int x;
W *next;
};
void main(){
W *q;
W *head;
W *s;
W *a;
head=(W *)malloc(sizeof(W));
cin>>head->x;
s=head;
for(int i=0;i<5;i++){
q=(W *)malloc(sizeof(W));
cin>>q->x;
s->next=q;
s=q;
}
q->next=NULL;
s=head;
a=(W *)malloc(sizeof(W));
a=s->next;
while(a->x!=NULL){
if(a->x==3){
s->next=a->next;
free(a);
break;
}
else{
s=s->next;
}
}
s=head;
for(int k=0;k<4;k++){
cout<<s->x;
s=s->next;}
}