#include <iostream>
#include <string>
#include <cctype>
using namespace std;

struct Node {
    string title;
    Node* next;
};

bool hasDigit(const string &s) {
    for (char c : s) {
        if (isdigit(static_cast<unsigned char>(c))) return true;
    }
    return false;
}

int main() {
    int n;
    if (!(cin >> n)) {
        cout << "Invalid input";
        return 0;
    }
    cin.ignore(); // consume newline

    Node* head = nullptr;
    Node* tail = nullptr;

    for (int i = 0; i < n; i++) {
        string line;
        getline(cin, line);
        if (hasDigit(line)) {
            cout << "Invalid input";
            return 0;
        }
        Node* newNode = new Node{line, nullptr};
        if (!head) {
            head = tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }

    string search;
    getline(cin, search);
    if (hasDigit(search)) {
        cout << "Invalid input";
        return 0;
    }

    Node* temp = head;
    int pos = 1;
    while (temp) {
        if (temp->title == search) {
            cout << pos;
            return 0;
        }
        temp = temp->next;
        pos++;
    }

    cout << "Title not found";
    return 0;
}