As in question, its given that all consecutive same characters that have length exactly B, we have remove so for test case:-

aaabc 2 answer should must be aaabc but all solution given will give answer abc…

soln:-

def solve(self, a, b):

c=1

i=0

s=""

while i<len(A):

c=1

j=i

while j<len(A)-1 and A[j]==A[j+1]:

j+=1

c+=1

```
if c!=B:
s+=c*A[i]
i+=c
return s
```