Help me in solving AO12 problem

My issue

logic please

My code

# Update the code below to solve the problem
def func(A,X):
    indexes=[]
    for s in A:
        if s < X:
            indexes.append(len(A) - 1 - A[::-1].index(s))
    
    if indexes!=[]:
        m=max(indexes)
        left=len(A[m+1:])
        print(len(A)-left)
    else:
        print(0)

t = int(input())
for i in range(t):
    N, X = map(int, input().split())
    A = list(map(int, input().split()))
    
    func(A,X)
    

Learning course: Python with Data structures
Problem Link: Practice Problem in - CodeChef