a = 'ACFDCBD' b = 'ABBB' print(len(a) - (a.count('AC') + a.count('DC')) * 2) print(len(b) - (b.count('AC') + b.count('DC')) * 2)