python  two lines code
\nclass Solution(object):\n    def minAddToMakeValid(self, S):\n        """\n        :type S: str\n        :rtype: int\n        """\n        \n        while "()
```\nclass Solution(object):\n    def minAddToMakeValid(self, S):\n        """\n        :type S: str\n        :rtype: int\n        """\n        \n        while "()" in S:\n            S = S.replace("()", "")\n        \n        return len(S)\n```
[]