n= int (input())
x= []
for i in range(n):
x.append(input().split()[0])
s= input()
if(s==x[i]):
print(i,end=" ")