#include <iostream>
#include <string>
#include <cctype>

using namespace std;

struct Node {
    string title;
    Node* next;
    Node(string t) : title(t), next(nullptr) {}
};

bool containsDigits(const string& s) {
    for (char c : s) {
        if (isdigit(c)) return true;
    }
    return false;
}

int main() {
    int n;
    if (!(cin >> n) || n < 1 || n > 500) {
        cout << "Invalid input" << endl;
        return 0;
    }

    cin.ignore();  // Ignore leftover newline after reading n

    Node* head = nullptr;
    Node* tail = nullptr;

    // Read titles
    for (int i = 0; i < n; i++) {
        string line;
        if (!getline(cin, line)) {
            cout << "Invalid input" << endl;
            return 0;
        }
        if (containsDigits(line)) {
            cout << "Invalid input" << endl;
            return 0;
        }

        Node* newNode = new Node(line);
        if (!head) {
            head = tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }

    // Read search query
    string query;
    if (!getline(cin, query)) {
        cout << "Invalid input" << endl;
        return 0;
    }
    if (containsDigits(query)) {
        cout << "Invalid input" << endl;
        return 0;
    }

    // Search the list
    Node* current = head;
    int pos = 1;
    while (current) {
        if (current->title == query) {
            cout << pos << endl;
            // Free memory
            while (head) {
                Node* tmp = head;
                head = head->next;
                delete tmp;
            }
            return 0;
        }
        current = current->next;
        pos++;
    }

    cout << "Title not found" << endl;

    // Free memory
    while (head) {
        Node* tmp = head;
        head = head->next;
        delete tmp;
    }

    return 0;
}