def BinarySearch(A, n, val):
left = 0
right = n - 1
a=[]
while left <= right:
mid = (left + right) // 2
if A[mid] == val :
if A.count(val)>1:
return A.index(val)
else:
return mid
elif A[mid] > val:
right = mid - 1
else:
left = mid + 1
else:
return -1
while True:
try:
l=input()
A = l[0]
n = l[1]
val = l[2]
print(BinarySearch(A, n, val))
except:
break