{"trustable":false,"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":"MD","content":"A balanced bracket sequence is a string consisting of only brackets, such that this sequence, when inserted certain numbers and mathematical operations, gives a valid mathematical expression. Formally you can define balanced bracket sequence with:\n\n- `e` (the empty string) is a balanced bracket sequence\n- if `s` is balanced bracket sequence, then so is `(s)`, `{s}`, `[s]`, and `\u003cs\u003e`.\n- if `s` and `t` are balanced bracket sequence, then so is `st`.\n\nFor instance, `[(\u003c\u003e)[]]{}` is a balanced bracket sequence, but `[)()` or `}{` are not.\n\nAs you can see from the discussion above, there are four kinds of brackets:\n\n- Parentheses \u0026xrarr; `()`\n- Curly braces \u0026xrarr; `{}`\n- Square brackets \u0026xrarr; `[]`\n- Pointy brackets \u0026xrarr; `\u003c\u003e`\n \nEach kind of brackets can be of two types, opening brackets and closing brackets.\n\nYou will be given a string **S** consisting of only opening and closing brackets of the four specified kinds. You can replace any kind of bracket of one type with another kind of bracket of the same type. For instance, `\u003c` can by replaced by `{`, but `(` cannot be replaced by `}` or `\u003e` and so on.\n\nYou need to find the minimum number of replacements required to transform **S** into a balanced bracket sequence."}},{"title":"Input","value":{"format":"MD","content":"Input contains a single string **S (1 \u0026le; S \u0026le; 10\u003csup\u003e6\u003c/sup\u003e)** \u0026mdash; the bracket sequence consisting of only opening and closing brackets mentioned in the problem description."}},{"title":"Output","value":{"format":"MD","content":"If it\u0027s not possible to convert **S** into a balanced bracket sequence, print \"`Impossible`\" (without the quotes).\nOtherwise, print the least number of replacements required."}},{"title":"Sample Input 1","value":{"format":"MD","content":"```\n{(\u003e]()\n```"}},{"title":"Sample Output 1","value":{"format":"MD","content":"```\n2\n```"}},{"title":"Sample Input 2","value":{"format":"MD","content":"```\n\u003e\u003e\n```"}},{"title":"Sample Output 2","value":{"format":"MD","content":"```\nImpossible\n```"}},{"title":"Explanation","value":{"format":"MD","content":"Consider the first sample:\nYou can replace `{` with `[` and `(` with `[` to balance the sequence.\nIn the second sample, it is not possible to balance the sequence, since we need to replace the first `\u003e` with `\u003c`, which is not allowed."}}]}