simple cpp solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\no(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\no(n)\n# Code\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        stack<char>st;\n        for(int i=0;i<s.length();i++)\n        {\n            if(s[i]==\')\')\n            {\n                if(!st.empty()&&st.top()==\'(\')\n                {\n                    st.pop();\n                }\n                else\n                {\n                    st.push(\')\');\n                }\n            }\n            else if(s[i]==\'(\')\n            {\n                st.push(\'(\');\n\n            }\n        }\n        return st.size();\n    }\n};\n```\n![upvote.jpg](https://assets.leetcode.com/users/images/756acd59-a50e-46a2-a537-6152e58a4c63_1676005189.21385.jpeg)\n\n
['String', 'Stack', 'C++']