Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.

Today was the pilot launch of an automated reading room visitors' accounting system! The scanner of the system is installed at the entrance to the reading room. It records the events of the form "reader entered room", "reader left room". Every reader is assigned a registration number during the registration procedure at the library — it's a unique integer from 1 to 10^6. Thus, the system logs events of two forms:  "+ r_{i}" — the reader with registration number r_{i} entered the room;  "- r_{i}" — the reader with registration number r_{i} left the room. 

The first launch of the system was a success, it functioned for some period of time, and, at the time of its launch and at the time of its shutdown, the reading room may already have visitors.

Significant funds of the budget of Berland have been spent on the design and installation of the system. Therefore, some of the citizens of the capital now demand to explain the need for this system and the benefits that its implementation will bring. Now, the developers of the system need to urgently come up with reasons for its existence.

Help the system developers to find the minimum possible capacity of the reading room (in visitors) using the log of the system available to you.


-----Input-----

The first line contains a positive integer n (1 ≤ n ≤ 100) — the number of records in the system log. Next follow n events from the system journal in the order in which the were made. Each event was written on a single line and looks as "+ r_{i}" or "- r_{i}", where r_{i} is an integer from 1 to 10^6, the registration number of the visitor (that is, distinct visitors always have distinct registration numbers).

It is guaranteed that the log is not contradictory, that is, for every visitor the types of any of his two consecutive events are distinct. Before starting the system, and after stopping the room may possibly contain visitors.


-----Output-----

Print a single integer — the minimum possible capacity of the reading room.


-----Examples-----
Input
6
+ 12001
- 12001
- 1
- 1200
+ 1
+ 7

Output
3
Input
2
- 1
- 2

Output
2
Input
2
+ 1
- 1

Output
1


-----Note-----

In the first sample test, the system log will ensure that at some point in the reading room were visitors with registration numbers 1, 1200 and 12001. More people were not in the room at the same time based on the log. Therefore, the answer to the test is 3.

Difficulty: interview

Starter code:

Solutions:
def main():
    n = int(input())
    
    result = 0
    d = set()
    for i in range(n):
        t, a = input().split()
        a = int(a)
        if t == "+":
            d.add(a)
            result = max(result, len(d))
        else:
            if a in d:
                d.remove(a)
            else:
                result += 1
    
    print(result)
    
    
main()


n = int(input())

room = set()
cap = 0

for i in range(n):
    typ, r = input().split()
    if typ == "+":
        room.add(r)
    else:
        if r in room:
            room.remove(r)
        else:
            cap += 1
    cap = max(cap, len(room))
print(cap)


n = int(input())

mn = mx = cur = 0
s = set()
for i in range(n):
    cmd = input()
    if cmd[0] == '+':
        s.add(int(cmd[2:]))
        cur += 1
        mx = max(mx, cur)
    else:
        cur -= 1
        try:
            s.remove(int(cmd[2:]))
        except KeyError:
            mn -= 1
print(mx - mn)


enum = int(input())
before = set()
cur = set()
events = [input().split() for i in range(enum)]
for i in range(enum):
    events[i][1] = int(events[i][1])
for i in range(enum):
    if events[i][0] == '-':
        if events[i][1] not in cur:
            before.add(events[i][1])
            cur.add(events[i][1])
        cur.remove(events[i][1])
    else:
        cur.add(events[i][1])

cur = before
max_l = len(cur)
for i in range(enum):
    if events[i][0] == '-':
        cur.remove(events[i][1])
    else:
        cur.add(events[i][1])
    max_l = max(max_l, len(cur))
print(max_l)


n = int(input())
col = 0
max = 0
p = []
q = []
e = []
for i in range(n):
    a, b = list(input().split())
    b = int(b)
    q.append([a, b])
    if a == '-' and b not in p:
        col += 1
        e.append(b)
    p.append(b)
for i in range(n):
    if col >= max:
        max = col
    if q[i][0] == '+':
        e.append(q[i][1])
        col += 1
    else:
        e.remove(q[i][1])
        col -= 1
    if col >= max:
        max = col
print(max)


n = int(input())

room = set()
maximum = 0
for _ in range(n):
    t, r = input().split()
    r = int(r)
    if t == '+':
        room.add(r)
        maximum = max(maximum, len(room))
    else:
        if r in room:
            room.remove(r)
        else:
            maximum += 1

print(maximum)

N = int(input())
number = 0
maxnum = 0
visitors = dict()
for n in range(N):
    inout, ID = input().split()
    if inout == '+':
        visitors[ID] = 1
        number += 1
    else:
        if ID not in visitors:
            maxnum += 1
        else:
            number -= 1
        visitors[ID] = 0
    if number > maxnum:
        maxnum = number
print(maxnum)


n = int(input())
ans = 0
k = 0
d = {}
for i in range(n):
    s = input()
    a = int(s[2:])
    if s[0] == '+':
        d[a] = 'yes'
        k += 1
        if k > ans:
            ans = k
    else:
        if a not in d:
            ans += 1
        else:
            d[a] = 'no'
            k -= 1
print(ans)

d = {}
z = 0
a = 0
n = int(input())
for e in range(n):
    u, v = input().split()
    v = int(v)
    if u == '+':
        z += 1
        d[v] = 1
    else:
        if d.get(v) == 1:
            d[v] = 0
            z -= 1
        else:
            a += 1
    a = max(a, z)
print(a)    


n = int(input())
l = [0] * (10 ** 6 + 1)
capacity = 0
cur = 0
for i in range(n):
    s = input().split()
    visitor = int(s[1])
    if s[0] == "+":
        l[visitor] = 1
        cur += 1
        if cur > capacity:
            capacity = cur
    else:
        if l[visitor] == 0:
            capacity += 1
        else:
            l[visitor] = 0
            cur -= 1
print (capacity)


def __starting_point():
    
    n = int( input() )

    visitors = set()
    basevisitors = set()

    log = []
    for _ in range(n):

        sign , ID = input().split()
        log.append( ( sign , ID ) )

        if sign == "+":
            visitors.add( ID )
        else:
            if ID in visitors:
                visitors.remove( ID )
            else:
                basevisitors.add( ID )


    res = len( basevisitors )
    for aLog in log:

        if aLog[0] == "+":
            basevisitors.add( aLog[1] )
            res = max( res , len(basevisitors) )
        else:
            basevisitors.remove( aLog[1] )

    print( res )

__starting_point()

c=[0]*1000001
n=int(input())
mi=ma=k=0
for i in range(n):
   a,b=input().split()
   b=int(b)
   if a=="+": k+=1; c[b]=1
   else: 
      if c[b]: k-=1; c[b]=0
      else: ma+=1
   ma=max(ma,k)
   mi=min(mi,k)
print(ma-mi)


n = int(input())
s = set()
now = set()
m = 0
for i in range(n):
    a = input().split()
    if a[0] == '+':
        now.add(a[1])
        s.add(a[1])
        if len(now) > m:
            m = len(now)
    else:
        if a[1] not in s:
            m = max(m, len(now)) + 1
            s.add(a[1])
        else:
            now.discard(a[1])
    #print(m)
    #print(now)
print(m)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n       = int(input())
now     = 0
max     = 0
readers = []

for i in range(n):
    (flag, N)  = (i for i in input().split())
    if flag == '+':
        now += 1
        if now > max:
            max = now

    else:
        if N not in readers:
            max += 1
        else:
            now -= 1

    if N not in readers:
        readers.append(N)

print(max)



__author__ = 'user'
n = int(input())
s = set()
ans = 0
x = set()
a = ["0"] * n
b = [0] * n
for i in range(n):
    type, id = map(str, input().split())
    a[i], b[i] = type, id
    id = int(id)
    if type == "+":
        s.add(id)
    elif type == "-":
        if id in s:
            s.remove(id)
        elif id not in s:
            x.add(id)

s.clear()
s = set(x)
ans = max(ans, len(s))
for i in range(n):
    type, id = a[i], b[i]
    id = int(id)
    if type == "+":
        s.add(id)
    elif type == "-":
        if id in s:
            s.remove(id)
    #print(s)
    ans = max(ans, len(s))
print(ans)

#!/usr/bin/env python3
"""
Codeforces
567 B.

@author yamaton
@date 2015-08-05
"""
import sys
import collections

def solve(xs):
    d = collections.defaultdict(int)
    already_in = collections.defaultdict(bool)
    for (sign, person) in xs:
        if sign == '+':
            d[person] += 1
        else:
            d[person] -= 1
        if d[person] < 0:
            already_in[person] = True

    number = sum(dict(already_in).values())
    history = [number]

    for (sign, person) in xs:
        if sign == '+':
            number += 1
        else:
            number -= 1
        history.append(number)

    return max(history)



# def print_stderr(*args, **kwargs):
#     print(*args, file=sys.stderr, **kwargs)

 
def main():
    n = int(input())
    xs = [input().strip().split() for _ in range(n)]
    result = solve(xs)
    print(result)


def __starting_point():
    main()

__starting_point()

n = int(input())

cmax = 0
curr = 0
records = set()

for i in range(n):
    line = input()
    r = int(line[2:])
    if line[0] == '+':
        curr += 1
        cmax = max(curr, cmax)
        records.add(r)
    else:
        if r in records:
            curr -= 1
            records.remove(r)
        else:
            cmax += 1

print(cmax)


n=int(input())
count=[0]*(1000001)
cur=0
ans=0
for i in range(n):
    c,d=input().split()
    d=int(d)
    if c=='-' and count[d]:
        cur-=1
        count[d]-=1
    elif c=='-' and not count[d]:
        ans=ans+1
    elif c=='+':
        cur+=1
        ans=max(ans,cur)
        count[d]+=1
print(ans)


a = int(input())
b = [0 for i in range(1000001)]
q = 0
cnt = 0
mx = 0
for i in range(a):
    z, x = input().split()
    x = int(x)
    if z == '+':
        b[x] = 1
        cnt += 1
    if z == '-':
        if b[x] == 0:
            mx = mx + 1
            cnt += 1
        b[x] = 0
        cnt -= 1
    mx = max(mx, cnt)
print(mx)


peoplein= 0
capacity= 0
n= int(input())
data= [0 for i in range(1, (10**6)+ 10)]

for i in range(n):
    a, b= input().split()
    b= int(b)
    
    if a== "+":
        data[b]= 1
        peoplein+= 1
        capacity= max(capacity, peoplein)
    elif a== "-":
        if data[b]== 0:
            data[b]= -1
            #peoplein-= 1
            capacity+= 1
        elif data[b]== 1:
            data[b]= -1
            peoplein-= 1

print(capacity)


n = int(input())
mas = [0] * n
dict = {}

for i in range(n):
	sign, r = input().split()
	r = int(r)
	if (i == 0):
		isMinus = sign == '-'		
	if sign == '+':
		dict[r] = i
	else:
		start = dict.get(r, 0)
		for j in range(start, i):
			mas[j] += 1
		dict.pop(r, None)
		
for i in dict.values():
	for j in range(i, n):
		mas[j] += 1

max = -1
mini = -1
for i in range(n):
	if mas[i] > max:
		max = mas[i]
		mini = i

if mini == 0 and isMinus:
	max += 1
print(max)

n = int(input());
minCapacity = 0;
capacity = 0;
readersIn = [];
for i in range(0, n):
    rec = input().split();
    if (rec[0] == '+'):
        capacity += 1;
        readersIn.append(rec[1]);
    elif (rec[0] == '-'):
        if(readersIn.__contains__(rec[1])):
            readersIn.remove(rec[1]);
            capacity -= 1;
        else:
            minCapacity += 1;
    if (capacity > minCapacity):
        minCapacity = capacity;

print((str(minCapacity)));


def main():
    n = int(input())
    initial_population = 0
    maximum_population = 0
    current_population = 0
    population_snapshots = [0] * (n + 1)
    population_set = set()

    def increase(index):
        if index > 0:
            population_snapshots[index] = population_snapshots[index - 1] + 1
        else:
            population_snapshots[index] = 1

    def copy(index):
        if index > 0:
            population_snapshots[index] = population_snapshots[index - 1]
        else:
            population_snapshots[index] = 0

    def decrease(index):
        population_snapshots[index] = population_snapshots[index - 1] - 1

    def increment_upto(end):
        for i in range(end + 1):
            population_snapshots[i] += 1

    for index in range(1, n + 1):
        direction, receipt = input().split()
        if direction == '+':
            increase(index)
            current_population += 1
            population_set.add(receipt)
        else:
            if receipt in population_set:
                decrease(index)
                current_population -= 1
                population_set.remove(receipt)
            else:
                copy(index)
                increment_upto(index - 1)
                initial_population += 1
        maximum_population = max(maximum_population, current_population)

    print(max(population_snapshots))


def __starting_point():
    main()

__starting_point()

ins = []
sumi = []
ous = []

n = int(input())
l = []
for i in range(n):
    l.append(str(input()))
    sumi.append(0)

sumi.append(0)

for i in range(n):
    if l[i][0] == "+":
        ins.append(l[i][2:len(l[i])])
        for j in range(i+1, n+1):
            sumi[j]+=1
    elif l[i][0] == "-" and l[i][2:len(l[i])] in ins:
        ins.remove(l[i][2:len(l[i])])
        for j in range(i+1, n+1):
            sumi[j]-=1
    else:
        for j in range(0, i+1):
            sumi[j]+=1
            

print(max(sumi))

n = int(input())
res = 0
nowin = []
for i in range(n):
    op, name = input().split()
    if op == "+":
        nowin.append(name)
        res = max(res, len(nowin))
    else:
        if name not in nowin:
            res += 1
        else:
            nowin.remove(name)
print(res)