# -*- coding: utf-8 -*-
import numpy as np
from copy import deepcopy

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    S = list(input())
    from_start = []
    from_end = []
    i = 0
    while True:
        i += 1
        if len(S)==0:
            print(len(from_start)+len(from_end))
            break
        elif len(S)==1:
            if (S[0]!=from_start[-1]) and (S[0]!=from_end[-1]):
                print(len(from_start)+len(from_end)+1)
                break
            else:
                print(len(from_start)+len(from_end))
                break
        else:
            if i % 2 ==0:
                if (len(from_start)==0) or (from_start[-1]!=S[0]):
                    from_start.append(S.pop(0))
                else:
                    from_start.append(S.pop(0)+S.pop(0))
            else:
                if (len(from_end)==0) or (from_end[-1]!=S[-1]):
                    from_end.append(S.pop(-1))
                else:
                    from_end.append(S.pop(-1)+S.pop(-1))

    # while True:
    #     if len(S)==0:

    # i = 0
    # while i<len(S):
    #     if (len(s_list)==0) or s_list[-1]!=S[i]:
    #         s_list.append(S[i])
    #         i += 1
    #     else:
    #         s_list.append(S[i]+S[i+1])
    #         i += 2
    # print(s_list)


if __name__=='__main__':
    main()
