//AMBRISAN
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef struct Node
{
    char title[205];
    struct Node *next;
}Node;
struct Node* newNode(const char *title)
{
    p = (Node)malloc(sizeof(Node));
    strcpy(p->title, title);
    p->next = NULL;
    return 0;
}
static void rstrip(char *s)
{
    size_t len = strlen(s);
    while (len && (s[len-1] == '\n' || s[len-1] == '\r'))
    {
        s[--len] = '\0';
    }
}
static int hasDigit(const char *s)
{
    for (size_t i = 0; s[i]; ++i)
        if (isdigit((unsigned char)s[i])) return 1;
    return 0;
}
int main(void)
{
    int n;
    if (scanf("%d", &n) != 1) return 0;
    int ch;
    while ((ch = getchar()) != '\n' && ch != EOF) {}
    Node *head = NULL, *tail = NULL;
    char buf[205];
    for (int i = 0; i < n; ++i)
    {
        if (!fgets(buf, sizeof(buf), stdin)) return 0;
        rstrip(buf);
        if (hasDigit(buf))
        {
            printf("Invalid input"); return 0; 
        }
        Node *nd = newNode(buf);
        if (!head) head = tail = nd;
        else 
        { 
            tail->next = nd; tail = nd;
        }
    }
    if (!fgets(buf, sizeof(buf), stdin))
    return 0;
    rstrip(buf);
    if (hasDigit(buf)) { printf("Invalid input");
    return 0; 
    }
    Node *cur = head;
    int pos = 1;
    while (cur) {
        if (strcmp(cur->title, buf) == 0)
        { printf("%d", pos); 
        return 0;
        }
        cur = cur->next;
        ++pos;
    }
    printf("Title not found");
    return 0;
}