{"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\u003eAlex was programming while Valentina (his toddler daughter) got there and started asking many questions about the round brackets (or parenthesis) in the code. He explained her a bit and when she got it he gave her a task in order to finish his code on time.\u003c/p\u003e\u003cp\u003eFor the purpose of this problem we consider only strings consisting of opening and closing round brackets, that is characters \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e(\u003c/span\u003e\u0027 and \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e)\u003c/span\u003e\u0027.\u003c/p\u003e\u003cp\u003eThe sequence of brackets is called \u003cspan class\u003d\"tex-font-style-it\"\u003ecorrect\u003c/span\u003e if: \u003c/p\u003e\u003col\u003e \u003cli\u003e it\u0027s empty; \u003c/li\u003e\u003cli\u003e it\u0027s a correct sequence of brackets, enclosed in a pair of opening and closing brackets; \u003c/li\u003e\u003cli\u003e it\u0027s a concatenation of two correct sequences of brackets. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eFor example, the sequences \"\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 \"\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.\u003c/p\u003e\u003cp\u003eAlex took a piece of paper, wrote a string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e consisting of brackets and asked Valentina to count the number of \u003cspan class\u003d\"tex-font-style-bf\"\u003edistinct\u003c/span\u003e non-empty substrings of \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e that are correct sequences of brackets. In other words, her task is to count the number of non-empty correct sequences of brackets that occur in a string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e as a \u003cspan class\u003d\"tex-font-style-bf\"\u003esubstring\u003c/span\u003e (don\u0027t mix up with subsequences).\u003c/p\u003e\u003cp\u003eWhen Valentina finished the task, Alex noticed he doesn\u0027t know the answer. Help him don\u0027t loose face in front of Valentina and solve the problem!\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains an integer \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 500 000\u003c/span\u003e)\u0026nbsp;— the length of the string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eThe second line contains a string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e of length \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e consisting of only \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e(\u003c/span\u003e\u0027 and \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e)\u003c/span\u003e\u0027.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint the number of \u003cspan class\u003d\"tex-font-style-bf\"\u003edistinct\u003c/span\u003e non-empty correct sequences that occur in \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e as substring.\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\u003e10\n()()()()()\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\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\u003e7\n)(())()\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\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 sample, there are \u003cspan class\u003d\"tex-span\"\u003e5\u003c/span\u003e distinct substrings we should count: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()()\u003c/span\u003e\", \"\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\".\u003c/p\u003e\u003cp\u003eIn the second sample, there are \u003cspan class\u003d\"tex-span\"\u003e3\u003c/span\u003e distinct substrings we should count: \"\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\".\u003c/p\u003e"}}]}