{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThe Beroil corporation structure is hierarchical, that is it can be represented as a tree. Let\u0027s examine the presentation of this structure as follows:\u003c/p\u003e\u003cul\u003e \u003cli\u003e \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eemployee\u003c/i\u003e\u003c/span\u003e ::\u003d \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ename\u003c/i\u003e\u003c/span\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003e.\u003c/span\u003e | \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ename\u003c/i\u003e\u003c/span\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003e:\u003c/span\u003e\u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eemployee\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003c/span\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003e,\u003c/span\u003e\u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eemployee\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\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-span\"\u003e\u003ci\u003eemployee\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ek\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003e.\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ename\u003c/i\u003e\u003c/span\u003e ::\u003d name of an employee \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThat is, the description of each employee consists of his name, a colon (\u003cspan class\u003d\"tex-font-style-tt\"\u003e:\u003c/span\u003e), the descriptions of all his subordinates separated by commas, and, finally, a dot. If an employee has no subordinates, then the colon is not present in his description.\u003c/p\u003e\u003cp\u003eFor example, line \u003cspan class\u003d\"tex-font-style-tt\"\u003eMIKE:MAX.,ARTEM:MIKE..,DMITRY:DMITRY.,DMITRY...\u003c/span\u003e is the correct way of recording the structure of a corporation where the director \u003cspan class\u003d\"tex-font-style-tt\"\u003eMIKE\u003c/span\u003e has subordinates \u003cspan class\u003d\"tex-font-style-tt\"\u003eMAX\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eARTEM\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eDMITRY\u003c/span\u003e. \u003cspan class\u003d\"tex-font-style-tt\"\u003eARTEM\u003c/span\u003e has a subordinate whose name is \u003cspan class\u003d\"tex-font-style-tt\"\u003eMIKE\u003c/span\u003e, just as the name of his boss and two subordinates of \u003cspan class\u003d\"tex-font-style-tt\"\u003eDMITRY\u003c/span\u003e are called \u003cspan class\u003d\"tex-font-style-tt\"\u003eDMITRY\u003c/span\u003e, just like himself.\u003c/p\u003e\u003cp\u003eIn the Beroil corporation every employee can only correspond with his subordinates, at that the subordinates are not necessarily direct. Let\u0027s call an uncomfortable situation the situation when a person whose name is \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e writes a letter to another person whose name is also \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e. In the example given above are two such pairs: a pair involving \u003cspan class\u003d\"tex-font-style-tt\"\u003eMIKE\u003c/span\u003e, and two pairs for \u003cspan class\u003d\"tex-font-style-tt\"\u003eDMITRY\u003c/span\u003e (a pair for each of his subordinates).\u003c/p\u003e\u003cp\u003eYour task is by the given structure of the corporation to find the number of uncomfortable pairs in it.\u003c/p\u003e\u003ccenter\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/08a091bfc2d93c27da76f20b9637ad2f?v\u003d1726399785\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/center\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first and single line contains the corporation structure which is a string of length from 1 to 1000 characters. It is guaranteed that the description is correct. Every name is a string consisting of capital Latin letters from 1 to 10 symbols in length.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint a single number — the number of uncomfortable situations in the company.\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\u003eMIKE:MAX.,ARTEM:MIKE..,DMITRY:DMITRY.,DMITRY...\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":"","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\u003eA:A..\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":"","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\u003eA:C:C:C:C.....\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}