{"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\u003ePolycarp is working on a new project called \"Polychat\". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands:\u003c/p\u003e\u003cul\u003e \u003cli\u003e Include a person to the chat (\u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Add\u0027\u003c/span\u003e command). \u003c/li\u003e\u003cli\u003e Remove a person from the chat (\u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Remove\u0027\u003c/span\u003e command). \u003c/li\u003e\u003cli\u003e Send a message from a person to all people, who are currently in the chat, including the one, who sends the message (\u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Send\u0027\u003c/span\u003e command). \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eNow Polycarp wants to find out the amount of outgoing traffic that the server will produce while processing a particular set of commands.\u003c/p\u003e\u003cp\u003ePolycarp knows that chat server sends no traffic for \u0027Add\u0027 and \u0027Remove\u0027 commands. When \u0027Send\u0027 command is processed, server sends \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003el\u003c/i\u003e\u003c/span\u003e bytes to each participant of the chat, where \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003el\u003c/i\u003e\u003c/span\u003e is the length of the message.\u003c/p\u003e\u003cp\u003eAs Polycarp has no time, he is asking for your help in solving this problem.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eInput file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following:\u003c/p\u003e\u003cul\u003e \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e+\u0026lt;name\u0026gt;\u003c/span\u003e for \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Add\u0027\u003c/span\u003e command. \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e-\u0026lt;name\u0026gt;\u003c/span\u003e for \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Remove\u0027\u003c/span\u003e command. \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0026lt;sender_name\u0026gt;:\u0026lt;message_text\u0026gt;\u003c/span\u003e for \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Send\u0027\u003c/span\u003e command. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0026lt;name\u0026gt;\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0026lt;sender_name\u0026gt;\u003c/span\u003e is a non-empty sequence of Latin letters and digits. \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0026lt;message_text\u0026gt;\u003c/span\u003e can contain letters, digits and spaces, but can\u0027t start or end with a space. \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0026lt;message_text\u0026gt;\u003c/span\u003e can be an empty line.\u003c/p\u003e\u003cp\u003eIt is guaranteed, that input data are correct, i.e. there will be no \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Add\u0027\u003c/span\u003e command if person with such a name is already in the chat, there will be no \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027Remove\u0027\u003c/span\u003e command if there is no person with such a name in the chat etc.\u003c/p\u003e\u003cp\u003eAll names are case-sensitive.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint a single number — answer to the problem.\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\u003e+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e9\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\u003e+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e14\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}