{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eOne day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.\u003c/p\u003e\u003cp\u003eA bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a \u003cspan class\u003d\"tex-font-style-it\"\u003ecorrect bracket sequence\u003c/span\u003e if it\u0027s possible to obtain a correct arithmetic expression by inserting characters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e+\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\" into this sequence. For example, the sequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(())()\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(()(()))\u003c/span\u003e\" are correct, while the bracket sequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)(\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(()\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(()))(\u003c/span\u003e\" are not correct.\u003c/p\u003e\u003cp\u003eYuhao found this problem too simple for him so he decided to make the problem harder. You are given many (not necessarily correct) bracket sequences. The task is to connect some of them into ordered pairs so that each bracket sequence occurs in at most one pair and the concatenation of the bracket sequences in each pair is a correct bracket sequence. The goal is to create as many pairs as possible.\u003c/p\u003e\u003cp\u003eThis problem unfortunately turned out to be too difficult for Yuhao. Can you help him and solve it?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$) — the number of bracket sequences.\u003c/p\u003e\u003cp\u003eEach of the following $$$n$$$ lines contains one bracket sequence — a non-empty string which consists only of characters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eThe sum of lengths of all bracket sequences in the input is at most $$$5 \\cdot 10^5$$$.\u003c/p\u003e\u003cp\u003eNote that a bracket sequence may appear in the input multiple times. In this case, you can use each copy of the sequence separately. Also note that the order in which strings appear in the input doesn\u0027t matter.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7\n)())\n)\n((\n((\n(\n)\n)\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n(\n((\n(((\n(())\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n(())\n()\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example, it\u0027s optimal to construct two pairs: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(( \u0026nbsp;\u0026nbsp;\u0026nbsp; )())\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e( \u0026nbsp;\u0026nbsp;\u0026nbsp; )\u003c/span\u003e\".\u003c/p\u003e"}}]}