Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen.

On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.

Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.


-----Input-----

The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.


-----Output-----

Print the sought minimum number of people


-----Examples-----
Input
+-+-+

Output
1

Input
---
Output
3

Difficulty: competition

Starter code:

Solutions:
m,p,c=0,0,0
s=(input())
for i in  s:
    if i=='-':
        c-=1
    else:
        c+=1    
    m=min(m,c)
    p=max(p,c)
print(p-m)


import math
import re
from fractions import Fraction
from collections import Counter

class Task:
    signs = ''
    answer = 0
    
    def __init__(self):
        self.signs = input()

    def solve(self):
        counter = 0
        leftBound, rightBound = 0, 0
        for x in self.signs:
            counter += 1 if x == '+' else -1
            leftBound = min(leftBound, counter)
            rightBound = max(rightBound, counter)
        self.answer = rightBound - leftBound

    def printAnswer(self):
        print(self.answer)

task = Task()
task.solve()
task.printAnswer()


3

inside = outside = 0
for c in list(input()):
    if c == '+':
        if outside:
            outside -= 1
        inside += 1
    else:
        if inside:
            inside -= 1
        outside += 1
print(inside + outside)


p = [0] + [1 if i == '+' else -1 for i in input()]
for i in range(1, len(p)):
    p[i] += p[i - 1]
print(max(p) - min(p))

s=input()
n=len(s)
x,a,b=0,0,0
for i in range(n):
  if s[i]=='-':
    x-=1
  else:
    x+=1
  a = min(a,x)
  b = max(b,x)
print(b-a)

a = [1 if x == '+' else -1 for x in input()]
b = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))
print(max(b) - min(b))

def puts(s):
    print(s, end='')

s = input()
a = mi = ma = 0

for c in s:
    if(c == '+'):
        a = a + 1
        ma = max(ma, a)
    else:
        a = a - 1
        mi = min(mi, a)

print(ma - mi)

inp=input()
inclb=0
outclb=0
seen=0
i=0
for i in range(0,len(inp)):
 if inp[i] == "-":
  outclb += 1
  if inclb > 0:
   inclb -= 1
  else:
   seen += 1
 else:
  inclb += 1
  if outclb > 0:
   outclb -= 1
  else:
   seen += 1
print(seen)

c, v1, v2 = 0, 0, 0
for ch in input():
    c += 1 if ch == '+' else -1
    v1, v2 = min(v1, c), max(v2, c)
print(v2 - v1)


s = input()
low = 0
high = 0
sum = 0
for i in s:
    if i == '+':
        sum += 1
    else:
        sum -= 1
    if sum < low:
        low = sum
    if sum > high:
        high = sum
print(high - low)

#!/usr/bin/env python3




def main():
    s = input()
    cnt = 0
    ans = 0
    for x in s:
        if x == '+':
            cnt += 1
            ans = max(ans, cnt)
        else:
            if cnt == 0:
                ans += 1
            else:
                cnt -= 1
    print(ans)


def __starting_point():
    main()

__starting_point()

S = input()

ans = 0
p, n = 0, 0
for i in range( len( S ) ):
  if S[ i ] == '+':
    p += 1
    n -= 1
  else:
    n += 1
    p -= 1
  n = max( 0, n )
  p = max( 0, p )
  ans = max( ans, max( n, p ) )

print( ans )


s = input()
mx = 0
mn = 0
cur = 0
for i in s:
  if i == '+':
    cur += 1
  else:
    cur -= 1
  mx = max(mx,cur)
  mn = min(mn,cur)
print(abs(mx-mn))

s = input()
t = mx = 0
for i in s:
    if i == '-' and t > 0:
        t -= 1
    elif i == '+':
        t += 1
        mx = max(mx, t)
    else:
        mx += 1
print(mx)

s=input()
a,b=0,0
for i in range(len(s)):
	if(s[i]=='-'):
		a=a-1
		if a<b:
			b=a
	else:
		a=a+1
a=-b
ans=a
for i in range(len(s)):
	if(s[i]=='-'):
		a=a-1 
	else:
		a=a+1
	if a>ans:ans=a
print(ans)

s = input()
plus = 0
minus = 0
seen = 0
for letter in s:
    if letter == '+':
        if minus == 0:
            plus += 1
            seen += 1
        else:
            plus += 1
            minus -= 1
    else:
        if plus == 0:
            minus += 1
            seen += 1
        else:
            minus += 1
            plus -= 1

print(seen)

s = input()
inside= 0
outside = 0
seen = 0
for letter in s:
    if letter == '+':
        if outside == 0:
            inside += 1
            seen += 1
        else:
            inside += 1
            outside -= 1
    else:
        if inside == 0:
            outside += 1
            seen += 1
        else:
            outside += 1
            inside -= 1

print(seen)

s=input()
s=list(s)
s1=[0]*len(s)
for i in range(len(s)):
    if s[i]=='-':
        s[i]=1
        s1[i]=-1 
    else:
        s[i]=-1 
        s1[i]=1 
def kadane(s):
    maxi=-1 
    curr=0 
    for i in s:
        curr=max(curr+i,i)
        maxi=max(maxi,curr)
    return maxi 
print(max(kadane(s),kadane(s1)))


s=input()
s=list(s)
s1=[0]*len(s)
for i in range(len(s)):
    if s[i]=='-':
        s[i]=1
        s1[i]=-1 
    else:
        s[i]=-1 
        s1[i]=1 
def kadane(s):
    maxi=-1 
    curr=0 
    for i in s:
        curr=max(curr+i,i)
        maxi=max(maxi,curr)
    return maxi 
print(max(kadane(s),kadane(s1)))
#@print(kadane(s))


s = input()
p = 0
m = 0

for i in s:
  if i == "+":
    p += 1
    m = max(m-1, 0)
  elif i == "-":
    m += 1
    p = max(p-1, 0)
print(p+m)


s = list(input())
ans = 0
while s.count('+') != 0 and s.count('-') != 0:
    flag = 0
    ans += 1
    if s.index('+') < s.index('-'):
        s[s.index('+')] = 0
        for i in range(1, len(s)):
            if flag == 0 and s[i] == '-':
                flag = 1
                s[i] = 0
            elif flag == 1 and s[i] == '+':
                flag = 0
                s[i] = 0
    elif s.index('-') < s.index('+'):
        s[s.index('-')] = 0
        for i in range(1, len(s)):
            if flag == 0 and s[i] == '+':
                flag = 1
                s[i] = 0
            elif flag == 1 and s[i] == '-':
                flag = 0
                s[i] = 0
print(max(ans + s.count('+'), ans + s.count('-')))


s=input()
ans=a1=a2=0
for i in s:
    if i=='+':
        ans+=1
    else:
        ans-=1
    a1=max(a1,ans)
    a2=min(a2,ans)
print(a1+abs(a2))            

l=list(input())
j=0
c=0
k=0
l1=0
e=0
p=0
while(j<len(l)):
    if(l[j]=='+'):
        p+=1
        k+=1
    else:
    
        l1+=1
        if(k>=e):
            c+=(k-e)
            e=k
            
        k-=1
        if(l1>p):
            l1-=1
            c+=1
        
        
            
       
    j+=1
if(k>e):
    c+=k-e

print(c)
        
        


s = input()

d, f, r = 0, 0, 0
for c in s:
    if c == "-":
        f += 1
        if d >= 1:
            d -= 1
        else:
            r += 1
    elif c == "+":
        d += 1
        if f >= 1:
            f -= 1
        else:
            r += 1

print(r)

def solve(s):
	n = len(s)
	if(n == 1):
		return 1
	else:
		start = 0
		prev = s[0]
		ans = 0
		f = 1
		for i in range(1,n):
			f = 1
			if(s[i] == prev):
				continue
			else:
				f = 0
				ans = max(ans,i-start)
				start = i
				prev = s[i]
				# print(ans)
		if(f):
			ans = max(ans,n-start)
			start = i
			prev = s[i]
		return ans

def solve1(s):
	st = []
	ans = 0
	maxx = 0
	for i in s:
		if(st):
			ans = 0
		if(i == '+'):
			st.append('+')
		else:
			if(st):
				st.pop()
			else:
				ans += 1
				maxx = max(maxx,ans)
		maxx = max(maxx,len(st))
		# print(st)
	maxx = max(maxx,len(st))
	return maxx

def solve2(s):
	st = []
	ans = 0
	maxx = 0
	for i in s:
		if(st):
			ans = 0
		if(i == '-'):
			st.append('-')
		else:
			if(st):
				st.pop()
			else:
				ans += 1
				maxx = max(maxx,ans)
		maxx = max(maxx,len(st))
		# print(st)
	maxx = max(maxx,len(st))
	return maxx

l = input()
ans = solve(l)
ans1 = solve1(l)
ans2 = solve2(l)
print(max(ans,ans1,ans2))