{"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\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003eThe only difference between the easy and the hard versions is constraints\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eA subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining symbols. Characters to be deleted are not required to go successively, there can be any gaps between them. For example, for the string \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabaca\u003c/span\u003e\" the following strings are subsequences: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabaca\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaba\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaa\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e\u003c/span\u003e\" (empty string). But the following strings are not subsequences: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaabaca\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ecb\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ebcaa\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eYou are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.\u003c/p\u003e\u003cp\u003eIn one move you can take \u003cspan class\u003d\"tex-font-style-bf\"\u003eany\u003c/span\u003e subsequence $$$t$$$ of the given string and add it to the set $$$S$$$. The set $$$S$$$ can\u0027t contain duplicates. This move costs $$$n - |t|$$$, where $$$|t|$$$ is the length of the added subsequence (i.e. the price equals to the number of the deleted characters).\u003c/p\u003e\u003cp\u003eYour task is to find out the minimum possible total cost to obtain a set $$$S$$$ of size $$$k$$$ or report that it is impossible to do so.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n, k \\le 100$$$) — the length of the string and the size of the set, correspondingly.\u003c/p\u003e\u003cp\u003eThe second line of the input contains a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint one integer — if it is impossible to obtain the set $$$S$$$ of size $$$k$$$, print \u003cspan class\u003d\"tex-font-style-tt\"\u003e-1\u003c/span\u003e. Otherwise, print the minimum possible total cost to do it.\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\u003e4 5\nasdf\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\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\u003e5 6\naaaaa\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e15\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\u003e5 7\naaaaa\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\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\u003e10 100\najihiushda\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e233\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 we can generate $$$S$$$ \u003d { \"\u003cspan class\u003d\"tex-font-style-tt\"\u003easdf\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003easd\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eadf\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003easf\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003esdf\u003c/span\u003e\" }. The cost of the first element in $$$S$$$ is $$$0$$$ and the cost of the others is $$$1$$$. So the total cost of $$$S$$$ is $$$4$$$.\u003c/p\u003e"}}]}