//创建链表首先要创建结构体作为节点

#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<stdlib.h>
    //宏定义
#define malloc(tp,sz) (tp*)malloc(sizeof(tp)*sz)

//类型重定义,既给结构体起一个别名:str
typedef struct people {    //结构体
    int data;
    struct people* next;
}str;

int main() {
    int n = 0;
    scanf("%d", &n);
    str* head = malloc(str, 1);    //创建头指针
    head->next = NULL;    //next为空
    str* p1 = head;    //p1是在整个链表之间移动的,所以我称之为游走指针哈哈
    int i = 0;
    for (i = 0; i < n; i++) {
        str* p2 = malloc(str, 1);    //创建一个新的节点
        p2->next = NULL;
        scanf("%d", &p2->data);    //赋值
        p1->next = p2;    //节点连接
        p1 = p2;
    }
    p1 = head;    //p1回到开始,继续在中间游走
    str* p2 = p1->next;    //从p2开始遍历链表寻找需要删除的值
    int del = 0;
    scanf("%d", &del);
    int sum = 0;
    for (i = 0; i < n; i++) {
        if (p2->data == del)
            p1->next = p2->next;    //找到需要删除的值便跳过本节点,P1位置不变
        else {
            sum++;
            p1->next = p2;    //否则连接该节点
            p1 = p2;    //p1改变指向,指到新节点
        }
            p2 = p2->next;    //遍历下一节点
    }
    printf("%d\n", sum);
    p1 = head->next;
    while (p1) {
        i++;
        printf("%d ", p1->data);
        p1 = p1->next;
    }
    return 0;
}