#include<stdio.h>
#include<stdlib.h>

struct List{
    int data;
    struct List *next;
};
void set_list(struct List *p,int n){
    int i=1;
    struct List *p1 = NULL;
    p1 = (struct List *)malloc(sizeof(struct List));
    p->next = p1;
    p1->next = NULL;
    scanf("%d",&(p1->data));
        while(n-1){
        set_list(p1, n-1);
        break;

    }
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    struct List *head = NULL;
    head = (struct List*)malloc(sizeof(struct List));
    set_list(head, n);
    struct List *p = head;
    struct List *q = NULL;
    while(p->next){
        if(p->next->data == m){
                q=p->next;
                p->next = p->next->next;
                free(q);
                continue;
        }
        p=p->next;
        
    }
    p=head->next;
    while(p){
        printf("%d ",p->data);
        p= p->next;
    }
    return 0;
}