inputed_list = list(input()) res = 1 tmp_list = [] for i in range(len(inputed_list)): tmp_list.clear() for e in inputed_list: tmp_list.append(e) j = 1 length = 1 limit = 0 if i < len(inputed_list) // 2: limit = i else: limit = len(inputed_list) - i for k in range(limit): try: b = tmp_list[i - j] f = tmp_list[i + j] if b == f or (b == 'b' and f == 'd') or (b == 'd' and f == 'b') or ( b == 'p' and f == 'q') or (b == 'q' and f == 'p'): length += 1 res = max(res, length) j += 1 else: tmp_list[i - j] = ' ' tmp_list[i + j] = ' ' j += 1 except: break if res == 1: print(0) else: print(res * 2 - 1)