n, m = map(int, input().split())
lst = [[int(x) for x in input().split()] for _ in range(n)]
k, row = int(input()), []
for i in range(n):
count = 0
for j in range(m):
if lst[i][j] == 0:
count += 1
if count == k:
row.append(i + 1)
if lst[i][j] == 1:
count = 0
print(min(row, default=0))