#include <stdio.h>

int main() {
    int n = 0;
    int arr[100];
    scanf("%d",&n);
    for(int i = 0;i < n;i++)
    {
        scanf("%d",&arr[i]);
    }
    int m = 0;
    scanf("%d",&m);
    int a = 0;
    int b = 0;
    int count = 0;
    while(n--)
    {
        if(arr[a] != m)
        {
            count++;
            arr[b++] = arr[a++];
        }
        else {
        a++;
        }
    }
    printf("%d\n",count);
    for(int i = 0;i < count;i++)
    {
        printf("%d ",arr[i]);
    }
    return 0;
}