eolymp
bolt
Try our new interface for solving problems
Problems

Bits Are Dangerous

Bits Are Dangerous

Do you think that escaping a dream is easy? This is not the case when the dream is about bits. You've surely read too much about bit theory yesterday, but this doesn't matter now as the only thing you want to do is to escape from the dream. You've probably found the best special string incorrectly... or they've just cheated you. You still have a long string of bits in front of your closed eyes. Then you realize that you have an ability to change the leftmost bit of this string from \textbf{0} to \textbf{1} or from \textbf{1} to \textbf{0}. It takes you exactly four seconds, but you can! Then 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. Something tells you that those \textbf{1}-bits in the string are what's keeping you in the dream. As this might be true, you decide to turn the string into a string of all zeroes  you know that you have everything required for that. But how much time would it take you if you acted optimally? \InputFile The only line contains \textbf{S }(\textbf{2} ≤ |\textbf{S}| ≤ \textbf{2}∙\textbf{10^5}) the string consisting of zeroes and ones. \OutputFile Print the sought minimum time you need to turn \textbf{S} into a string of all zeroes, in seconds. \Note In the first test case, the optimal strategy is the following: change the leftmost bit to get \textbf{01001}, shift the string cyclically to the left to get \textbf{10010}, change the leftmost bit to get \textbf{00010}, shift the string cyclically to the right to get \textbf{00001}, shift the string cyclically to the right (again) to get \textbf{10000}, and then change the leftmost bit to get \textbf{00000}. Three changes and three cyclic shifts would take you exactly \textbf{33} seconds.
Time limit 1 second
Memory limit 64 MiB
Input example #1
11001
Output example #1
33
Author Gennady Korotkevich
Source Gennady Korotkevich Contest 1, Petrozavodsk Training Camp, Day 1, Friday, August 23, 2013