S =  input()

j = 0
diff = []
for ltr in S:
    if ltr == '?':
        j += 1
        # print(j)
        diff.append(j)
    else:   
        j = 0
if S[-1] == '?':
    print(max(diff) - min(diff))
else:
    print(max(diff))