local s = io.read() local n = #s local t = {} local curlen = 1 for i = 2, n do if s:sub(i, i) == "0" then table.insert(t, curlen) curlen = 0 else if curlen == 0 then table.insert(t, 0) end curlen = curlen + 1 end end table.insert(t, curlen) table.insert(t, 0) local cnt = 0 local curleft = 1 local curpos = 2 while curpos <= #t do if curpos == #t or t[curpos + 1] == 0 then if 1 < t[curleft] then cnt = cnt + 2 else cnt = cnt + 1 end while curpos <= #t and t[curpos] == 0 do curpos = curpos + 1 end curleft = curpos curpos = curleft + 1 else if 1 < t[curleft] or 1 < t[curpos + 1] then cnt = cnt + 1 t[curleft] = 2 curpos = curpos + 2 else cnt = cnt + 1 curleft = curpos curpos = curpos + 2 end end end print(cnt)