import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
//二分查找
public static int getIndex(String[] strs, String str) {
if (strs == null || strs.length == 0 || str == null) {
return -1;
}
int res = -1; //返回的位置
int left = 0;
int right = strs.length - 1;
int mid = 0;
int i = 0;
while (left <= right) {
mid = (left + right) / 2;
//1、找到了
if (strs[mid] != null && strs[mid].equals(str)) {
res = mid;
right = mid - 1;
} else if (strs[mid] != null) {//2、没找到,mid处不为null
if (strs[mid].compareTo(str) < 0) {//2.1 找右半区
left = mid +1;
} else { //2.2 找左半区
right = mid - 1;
}
}else{//3. mid处为null
i=mid;
//找不等于null的位置
while (strs[i]==null&&--i>=left)
;
if(i<left||strs[i].compareTo(str)<0){
left=mid+1;
}else{
res=strs[i].equals(str)?i:res;
right=i-1;
}
}
}
return res;
}
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bf.readLine());
String str = bf.readLine();
String[] data = new String[n];
for (int i = 0; i < n; i++) {
data[i] = bf.readLine();
data[i] = data[i].equals("0") ? null : data[i];
}
bf.close();
System.out.println(getIndex(data, str));
}
}