def solve(s):
    if not "-" in s:
        return 0
    if not "+" in s:
        return 1
    cnt = 0
    while "-" in s:
        if s[0] == '+':
            idx = s.index('-')
            s = idx * "-" + s[idx:]
            #print(s)
            cnt += 1
        else:
            idx = s.rindex('-') + 1
            s = "".join({"+":"-", "-":"+"}[i] for i in s[:idx]) + s[idx:]
            #print(s)
            cnt += 1
    return cnt


t = int(input())
for i in range(t):
    s = input().strip()
    print("Case #%d: %d" % (i+1, solve(s)))

c39c7851a8b9a8ebf771b1b5b2a1d42dc1c31c90
<mask token>

def solve(s):
    if not '-' in s:
        return 0
    if not '+' in s:
        return 1
    cnt = 0
    while '-' in s:
        if s[0] == '+':
            idx = s.index('-')
            s = idx * '-' + s[idx:]
            cnt += 1
        else:
            idx = s.rindex('-') + 1
            s = ''.join({'+': '-', '-': '+'}[i] for i in s[:idx]) + s[idx:]
            cnt += 1
    return cnt


<mask token>

def solve(s):
    if not '-' in s:
        return 0
    if not '+' in s:
        return 1
    cnt = 0
    while '-' in s:
        if s[0] == '+':
            idx = s.index('-')
            s = idx * '-' + s[idx:]
            cnt += 1
        else:
            idx = s.rindex('-') + 1
            s = ''.join({'+': '-', '-': '+'}[i] for i in s[:idx]) + s[idx:]
            cnt += 1
    return cnt


<mask token>
for i in range(t):
    s = input().strip()
    print('Case #%d: %d' % (i + 1, solve(s)))

def solve(s):
    if not '-' in s:
        return 0
    if not '+' in s:
        return 1
    cnt = 0
    while '-' in s:
        if s[0] == '+':
            idx = s.index('-')
            s = idx * '-' + s[idx:]
            cnt += 1
        else:
            idx = s.rindex('-') + 1
            s = ''.join({'+': '-', '-': '+'}[i] for i in s[:idx]) + s[idx:]
            cnt += 1
    return cnt


t = int(input())
for i in range(t):
    s = input().strip()
    print('Case #%d: %d' % (i + 1, solve(s)))

def solve(s):
    if not "-" in s:
        return 0
    if not "+" in s:
        return 1
    cnt = 0
    while "-" in s:
        if s[0] == '+':
            idx = s.index('-')
            s = idx * "-" + s[idx:]
            #print(s)
            cnt += 1
        else:
            idx = s.rindex('-') + 1
            s = "".join({"+":"-", "-":"+"}[i] for i in s[:idx]) + s[idx:]
            #print(s)
            cnt += 1
    return cnt


t = int(input())
for i in range(t):
    s = input().strip()
    print("Case #%d: %d" % (i+1, solve(s)))
