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