#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef struct Node {
    char *title;
    int position;
    struct Node *next;
} Node;
int containsNumbers(const char *str) {
    for (int i = 0; str[i] != '\0'; i++) {
        if (isdigit(str[i])) {
            return 1;
        }
    }
    return 0;
}
Node* createNode(const char *title, int position) {
    Node newNode = (Node)malloc(sizeof(Node));
    newNode->title = strdup(title);
    newNode->position = position;
    newNode->next = NULL;
    return newNode;
}
void freeList(Node *head) {
    Node *current = head;
    while (current != NULL) {
        Node *temp = current;
        current = current->next;
        free(temp->title);
        free(temp);
    }
}
int main() {
    int n;
    char buffer[1000];
    if (fgets(buffer, sizeof(buffer), stdin) != NULL) {
        n = atoi(buffer);
    } else {
        printf("invalid input\n");
        return 1;
    }
    Node *head = NULL;
    Node *tail = NULL;
    int invalidInput = 0;
    for (int i = 0; i < n; i++) {
        if (fgets(buffer, sizeof(buffer), stdin) != NULL) {
            size_t len = strlen(buffer);
            if (len > 0 && buffer[len - 1] == '\n') {
                buffer[len - 1] = '\0';
            }
            if (containsNumbers(buffer)) {
                invalidInput = 1;
                break;
            }
            Node *newNode = createNode(buffer, i + 1);
            if (head == NULL) {
                head = newNode;
                tail = newNode;
            } else {
                tail->next = newNode;
                tail = newNode;
            }
        }
    }
    char searchTitle[1000];
    if (fgets(searchTitle, sizeof(searchTitle), stdin) != NULL) {
        size_t len = strlen(searchTitle);
        if (len > 0 && searchTitle[len - 1] == '\n') {
            searchTitle[len - 1] = '\0';
        }
        if (containsNumbers(searchTitle)) {
            invalidInput = 1;
        }
    }
    if (invalidInput) {
        printf("invalid input\n");
        freeList(head);
        return 1;
    }
    Node *current = head;
    int found = 0;
    int position = 0;
    while (current != NULL) {
        if (strcmp(current->title, searchTitle) == 0) {
            found = 1;
            position = current->position;
            break;
        }
        current = current->next;
    }
    if (found) {
        printf("%d\n", position);
    } else {
        printf("Title not found\n");
    }
    freeList(head);
    return 0;
}