lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end s = (read_line.reverse + '0').chars n = s.size ans = 0 (0...n).each do |i| if s[i] == '1' if (s[i + 1]? || '0') == '0' s[i] = '0' else while s[i] == '1' s[i] = '0' i += 1 end s[i] = '1' end ans += 1 end end puts ans