#include bool all_ones(const std::string & line) { for (const char i : line) { if (i != '1' and i != '\n') { return false; } } return true; } int main(int, char**) { std::string line; std::getline(std::cin, line); size_t days = 0; while (not all_ones(line)) { auto copy = line; bool day_changed = false; for (size_t i = 0; i < line.length(); ++i) { if (i > 0 and line[i] == '1') { day_changed = day_changed or copy[i-1] == '0'; copy[i-1] = '1'; } if (i < line.length()-1 and line[i] == '1') { day_changed = day_changed or copy[i+1] == '0'; copy[i+1] = '1'; } } days += day_changed; line = copy; } std::cout << days << std::endl; }