2 solutions | Easy to Understand | Faster | Simple | Python Solution
\n    def without_stack(self, S):\n        opening = count = 0\n        for i in S:\n            if i == \'(\': \n                opening += 1\n            else
```\n    def without_stack(self, S):\n        opening = count = 0\n        for i in S:\n            if i == \'(\': \n                opening += 1\n            else:\n                if opening: opening -= 1\n                else: count += 1\n        return count + opening\n        \n    def using_stack(self, S):\n        stack = []\n        for ch in S:\n            if ch == \'(\': stack.append(ch)\n            else:\n                if len(stack) and stack[-1] == \'(\': stack.pop()\n                else: stack.append(ch)\n        return len(stack)\n```\n\n**I hope that you\'ve found the solution useful.**\n*In that case, please do upvote and encourage me to on my quest to document all leetcode problems\uD83D\uDE03*\nPS: Search for **mrmagician** tag in the discussion, if I have solved it, You will find it there\uD83D\uDE38
['Stack', 'Python', 'Python3']