1 class Solution: 2 def isValid(self, S: str) -> bool: 3 n = len(S) 4 if n % 3 != 0: 5 return False 6 while n!=0: 7 i = S.find('abc') 8 if i == -1: 9 return False 10 else: 11 S = S[0:i] + S[i+3:] 12 n = len(S) 13 return True