#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define MAX_TITLE_LEN 1000

// Node structure for linked list
typedef struct Node {
    char *title;
    struct Node *next;
} Node;

// Function to check if a string contains any digit
int containsDigit(const char *s) {
    while (*s) {
        if (isdigit((unsigned char)*s)) return 1;
        s++;
    }
    return 0;
}

// Function to create a new node with a given title
Node* createNode(const char *title) {
    Node newNode = (Node)malloc(sizeof(Node));
    if (!newNode) {
        printf("Memory allocation failed\n");
        exit(1);
    }
    newNode->title = strdup(title);
    newNode->next = NULL;
    return newNode;
}

// Append node to end of list
void appendNode(Node **head, const char *title) {
    Node *newNode = createNode(title);  // must use Node newNode (as per Note)
    if (*head == NULL) {
        *head = newNode;
    } else {
        Node *temp = *head;
        while (temp->next) temp = temp->next;
        temp->next = newNode;
    }
}

// Free linked list memory
void freeList(Node *head) {
    while (head) {
        Node *tmp = head;
        head = head->next;
        free(tmp->title);
        free(tmp);
    }
}

int main() {
    int n;
    if (scanf("%d\n", &n) != 1 || n < 1 || n > 500) {
        printf("Invalid input");
        return 0;
    }

    Node *head = NULL;
    char buffer[MAX_TITLE_LEN];

    // Read titles into linked list
    for (int i = 0; i < n; i++) {
        if (!fgets(buffer, sizeof(buffer), stdin)) {
            printf("Invalid input");
            freeList(head);
            return 0;
        }
        buffer[strcspn(buffer, "\n")] = '\0';  // remove newline
        if (containsDigit(buffer)) {
            printf("Invalid input");
            freeList(head);
            return 0;
        }
        appendNode(&head, buffer);
    }

    // Read search query
    if (!fgets(buffer, sizeof(buffer), stdin)) {
        printf("Invalid input");
        freeList(head);
        return 0;
    }
    buffer[strcspn(buffer, "\n")] = '\0';
    if (containsDigit(buffer)) {
        printf("Invalid input");
        freeList(head);
        return 0;
    }

    // Search through the linked list
    Node *current = head;
    int index = 1;
    while (current) {
        if (strcmp(current->title, buffer) == 0) {
            printf("%d", index);
            freeList(head);
            return 0;
        }
        current = current->next;
        index++;
    }

    // Not found
    printf("Title not found");
    freeList(head);
    return 0;
}

/*
Note:
 Must use Node newNode in the program — we created a Node* newNode inside appendNode.

Constraints:
 1 <= n <= 500

Sample Input 1:
4
The Odyssey
Moby Dick
Hamlet
Pride and Prejudice
Hamlet

Sample Output 1:
3
*/