Help me in solving ABCC3 problem

My issue

I have almost solved the problem but, missing something.

My code

# cook your dish here
def choose(arr,n):
	s = [-1,-1,-1]
	for i in range(len(arr)):
		if arr[i] == 'a':
			if s[0] == -1:
				s[0] = i
		elif arr[i] == 'b':
			if s[1] == -1 and s[0] !=-1:
				s[1] = i
		elif arr[i] == 'c':
			if s[2] == -1 and s[0] !=-1 and s[1] !=-1:
				s[2] = i
				break
	if -1 in s:
		return 0
	return s
	
def remove(arr,s):
	x,y = co(arr,s)
	if x >= y:
		arr.pop(s[0])
	else:
		arr.pop(s[2])
	return arr				

def co(arr, s):
	a = arr.count('a')
	c = arr.count('c')
	return a,c
				
for _ in range(int(input())):
    n = int(input())
    arr = list(input())
    c = 0
    while True:
        s = choose(arr,n)
        if s ==0:
            if c!=0:
                print(c-1)
            else:
                print(c)
            break
        arr = remove(arr,s)
        c+=1

Problem Link: ABC Conjecture 3 Practice Coding Problem - CodeChef