
length = 0
ans = 0

def remove_data(data, ind_pre, ind_after):
    if ind_pre == 0:
        data_pre = ''
    else:
        data_pre = data[:ind_pre]
    if ind_after == len(data) - 1:
        data_after = ''
    else:
        data_after = data[ind_after + 1:]
    data_remove = data_pre + data_after
    return data_remove

def calc_ans(data):
    global length, ans
    ans_kari = length - len(data)
    if ans_kari > ans:
        ans = ans_kari


def calc_data(data):
    for i in range(len(data) - 1):
        if data[i] != data[i + 1]:
            data_remove = remove_data(data, i, i+1)
            calc_data(data_remove)
    calc_ans(data)

def main():
    global length, ans
    data = input()
    length = len(data)
    calc_data(data)
    print(ans)


if __name__ == '__main__':
    main()