#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct Node {
    char title[100];
    struct Node* next;
} Node;

int containsDigit(const char* str) {
    for (int i = 0; str[i]; i++) {
        if (isdigit(str[i])) return 1;
    }
    return 0;
}

struct Node* newNode(const char* title) ;

int main() {
    int n;
    if (scanf("%d\n", &n) != 1 || n < 1 || n > 500) {
        printf("Invalid input\n");
        return 0;
    }

    Node* head = NULL;
    Node* tail = NULL;
    char buffer[100];
    for (int i = 0; i < n; i++) {
        fgets(buffer, sizeof(buffer), stdin);
        buffer[strcspn(buffer, "\n")] = '\0'; 

        if (containsDigit(buffer)) {
            printf("Invalid input\n");
            return 0;
        }

        Node* node = newNode(buffer);
        if (!head) {
            head = tail = node;
        } else {
            tail->next = node;
            tail = node;
        }
    }
    fgets(buffer, sizeof(buffer), stdin);
    buffer[strcspn(buffer, "\n")] = '\0'; 

    if (containsDigit(buffer)) {
        printf("Invalid input\n");
        return 0;
    }

    Node* temp = head;
    int position = 1;
    while (temp) {
        if (strcmp(temp->title, buffer) == 0) {
            printf("%d\n", position);
            return 0;
        }
        temp = temp->next;
        position++;
    }

    //printf("Title not found\n");
    return 0;
}