# # coding: utf-8
# data = list(input())
# removed_block = 0
# i = 1
# log = data[0]
# while i < (len(data) + 1):
#     try:
#         if data[i] != log:
#             data.pop(i)
#             data.pop(i - 1)
#             removed_block += 2
#             i = 1
#             log = data[0]
#         else:
#             i += 1
#     except:
#         break
# print(removed_block)

# coding: utf-8
n = input()
print(min(n.count('0'), n.count('1')))
