From Mungo Penguin, 3 Months ago, written in Text.
Embed
  1. o = c = 0
  2. for e in eval(dir()[0])[0]:
  3.     f = e > '('
  4.     if f * c:
  5.         c -= 2
  6.    
  7.     o += f * (not c)
  8.     c += 1
  9. return o + c/2