def solution(s):
answer = 0
t = {} ; a = s[0] ; k = "no"+a
for i in s:
if len(t)==0:
answer += 1
t[i] = 1
a = i
else:
k = "no"+a
if i == a:
t[a] += 1
else:
if k in t:
t[k] += 1
else:
t[k] = 1
if a in t and k in t and t[a] == t[k]:
del t[a]
del t[k]
return answer