# ??00????0??0????0?0??00??1???11?1?1???1?11?111???1
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))



s = rr()
temp = s[0]
cnt = 0
li = []
for i in range(len(s) - 1):
    if s[i] == s[i+1] and temp == s[i]:
        cnt += 1
        continue
    else:
        li.append([temp, cnt+1])
        cnt = 0
        temp = s[i+1]
else:
    li.append([temp, cnt+1])
m = 1
for i in range(len(li) - 2):
    if li[i][0] == li[i+2][0] and li[i+1][0] == 63:
        if li[i+1][1] & 1:
            aaa = li[i][1] + li[i+2][1] - 1
            m = max(aaa, m)
        else:
            if li[i][1] == li[i+2][1]:
                m = max(li[i+2][1]+1, m)
            else:
                m = max(li[i+2][1], li[i][1], m)
    elif li[i][0] != 63:
        m = max(li[i][1], m)
print(m)

    





