// editor4
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct Node {
    char title[101];   
    struct Node* next;
} Node;
Node* createNode(char *title) {
    Node* newNode = (Node*)malloc(sizeof(Node));
    strcpy(newNode->title, title);
    newNode->next = NULL;
    return newNode;
}
int hasDigits(char *str) {
    for (int i = 0; str[i]; i++) {
        if (isdigit(str[i]))
            return 1;
    }
    return 0;
}
void insertEnd(Node **head, char *title) {
    Node *newNode = createNode(title);
    if (*head == NULL) {
        *head = newNode;
    }
    Node *temp = *head;
    while (temp->next != NULL) {
        temp = temp->next;
    }
    temp->next = newNode;
}
int searchTitle(Node *head, char *query) {
    int pos = 1;
    while (head != NULL) {
        if (strcmp(head->title, query) == 0) {
            return pos;
        }
        head = head->next;
        pos++;
    }
    return -1; 
}

int main() {
    int n;
    scanf("%d", &n);
    getchar(); 
    Node *head = NULL;
    char title[101];
    for (int i = 0; i < n; i++) {
        fgets(title, sizeof(title), stdin);
        title[strcspn(title, "\n")] = '\0'; 
        if (hasDigits(title)) {
            printf("Invalid input\n");
            return 0;
        }
        insertEnd(&head, title);
    }
    fgets(title, sizeof(title), stdin);
    title[strcspn(title, "\n")] = '\0';

    if (hasDigits(title)) {
        printf("Invalid input\n");
        return 0;
    }
    int pos = searchTitle(head, title);

    if (pos == -1) {
        printf("Title not found\n");
    } else {
        printf("%d\n", pos);
    }
    return 0;
}