{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eDo you think that escaping a dream is easy? This is not the case when the dream is about bits. You\u0027ve surely read too much about bit theory yesterday, but this doesn\u0027t matter now as the only thing you want to do is to escape from the dream. You\u0027ve probably found the best special string incorrectly... or they\u0027ve just cheated you. You still have a long string of bits in front of your closed eyes.\u003c/p\u003e\n\n\u003cp\u003eThen you realize that you have an ability to change the leftmost bit of this string from \u003cstrong\u003e0\u003c/strong\u003e to \u003cstrong\u003e1\u003c/strong\u003e or from \u003cstrong\u003e1\u003c/strong\u003e to \u003cstrong\u003e0\u003c/strong\u003e. It takes you exactly four seconds, but you can!\u003c/p\u003e\n\n\u003cp\u003eThen you realize that you can also shift this string cyclically, one position to the left or one position to the right. Either of the actions takes you a whopping total of seven seconds in this strange dream.\u003c/p\u003e\n\n\u003cp\u003eSomething tells you that those \u003cstrong\u003e1\u003c/strong\u003e-bits in the string are what\u0027s keeping you in the dream. As this might be true, you decide to turn the string into a string of all zeroes \u0016 you know that you have everything required for that.\u003c/p\u003e\n\n\u003cp\u003eBut how much time would it take you if you acted optimally?\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eInput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eThe only line contains \u003cstrong\u003eS \u003c/strong\u003e(\u003cstrong\u003e2\u003c/strong\u003e ≤ |\u003cstrong\u003eS\u003c/strong\u003e| ≤ \u003cstrong\u003e2\u003c/strong\u003e∙\u003cstrong\u003e10^5\u003c/strong\u003e) \u0016the string consisting of zeroes and ones.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eOutput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003ePrint the sought minimum time you need to turn \u003cstrong\u003eS\u003c/strong\u003e into a string of all zeroes, in seconds.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eNote\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eIn the first test case, the optimal strategy is the following: change the leftmost bit to get \u003cstrong\u003e01001\u003c/strong\u003e, shift the string cyclically to the left to get \u003cstrong\u003e10010\u003c/strong\u003e, change the leftmost bit to get \u003cstrong\u003e00010\u003c/strong\u003e, shift the string cyclically to the right to get \u003cstrong\u003e00001\u003c/strong\u003e, shift the string cyclically to the right (again) to get \u003cstrong\u003e10000\u003c/strong\u003e, and then change the leftmost bit to get \u003cstrong\u003e00000\u003c/strong\u003e. Three changes and three cyclic shifts would take you exactly \u003cstrong\u003e33\u003c/strong\u003e seconds.\u003c/p\u003e\n\n"}},{"title":"Example","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\u003e11001\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e33\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}