#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct Node {
    char title[100];
    struct Node *next;
} Node;

Node* newNode(char *bookTitle) {
    Node temp = (Node)malloc(sizeof(Node));
    strcpy(temp->title, bookTitle);
    temp->next = NULL;
    return temp;
}

int containsDigit(char *str) {
    for (int i = 0; str[i] != '\0'; i++) {
        if (isdigit((unsigned char)str[i])) return 1;
    }
    return 0;
}

// Trim leading and trailing whitespace (including \r, \n, spaces, tabs)
void trim(char *str) {
    // Trim leading
    char *start = str;
    while (isspace((unsigned char)*start)) start++;

    // Move trimmed string to beginning
    if (start != str) memmove(str, start, strlen(start) + 1);

    // Trim trailing
    int len = strlen(str);
    while (len > 0 && isspace((unsigned char)str[len - 1])) {
        str[len - 1] = '\0';
        len--;
    }
}

int searchBook(Node *head, char *searchTitle) {
    int position = 1;
    Node *temp = head;
    while (temp != NULL) {
        if (strcmp(temp->title, searchTitle) == 0) {
            return position;
        }
        temp = temp->next;
        position++;
    }
    return -1;
}

int main() {
    int n;
    char buffer[200];
    Node *head = NULL, *tail = NULL;

    // Read number of books
    if (!fgets(buffer, sizeof(buffer), stdin) || sscanf(buffer, "%d", &n) != 1) {
        printf("Invalid input\n");
        return 0;
    }
    if (n < 1 || n > 500) {
        printf("Invalid input\n");
        return 0;
    }

    // Read book titles
    for (int i = 0; i < n; i++) {
        if (!fgets(buffer, sizeof(buffer), stdin)) {
            printf("Invalid input\n");
            return 0;
        }
        buffer[strcspn(buffer, "\n")] = '\0';  // remove \n
        trim(buffer);
        if (containsDigit(buffer) || strlen(buffer) == 0) {
            printf("Invalid input\n");
            return 0;
        }
        Node *node = newNode(buffer);
        if (head == NULL) {
            head = tail = node;
        } else {
            tail->next = node;
            tail = node;
        }
    }

    // Read search title
    if (!fgets(buffer, sizeof(buffer), stdin)) {
        printf("Invalid input\n");
        return 0;
    }
    buffer[strcspn(buffer, "\n")] = '\0';
    trim(buffer);
    if (containsDigit(buffer) || strlen(buffer) == 0) {
        printf("Invalid input\n");
        return 0;
    }

    int position = searchBook(head, buffer);
    if (position == -1) {
        printf("Title not found\n");
    } else {
        printf("%d\n",position);
    }
    return 0;
}