D-berland National Library

Source: Internet
Author: User

Berland National Library had 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 have a reading class .

Today is the pilot launch of an automated reading visitors ' accounting system! The scanner of the system is installed in the entrance to the reading. It records the events of the form "reader entered", "reader left". Every reader is assigned a registration number during the Registration Procedure at the Library-it ' s a unique integer from 1 to  106. Thus, the system logs events of both forms:

    • "+ ri"-the Reader with registration number rI entered the hostel;
    • "- Ri"-the Reader with registration number ri left the.

The first launch of the system is 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. already has visitors.

Significant funds of the budget of Berland has 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, it IM Plementation would 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 a (in visitors) using the log of the SY Stem 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 is written on a single line and looks as "+  R i "or" -  R i ", Where  R i  is an integer from 1 to 106, the registration number of the visitor (that's, distinct visitors always has D ISTINCT registration numbers).

It is guaranteed that the log was not contradictory, that's, for every visitor the types of any of his and consecutive Eve NTS is distinct. Before starting the system, and after stopping the "the" the "may possibly contain visitors.

Output

Print a single integer-the minimum possible capacity of the reading.

Examples

Input
6
+ 12001
-12001
-1
-1200
+ 1
+ 7
Output
3
Input
2
-1
+ t
Output
2
Input
2
+ 1
-1
Output
1

Note

In the first sample test, the system log would ensure that at some point in the reading-were visitors with Registratio N numbers 1, and 12001. More people were "not" in the "the" same time based on the log. Therefore, the answer to the test is 3.

#include <cstdio> #include <algorithm>using namespace std;const int maxm = 1e6 + 5;int n;int Flag[maxm] = {0};int Main () {scanf ("%d", &n), char c;int m;int res1 = 0, res2 = 0, num = 0;while (num! = n && scanf ("%c%d", &c, &m) = = 2) {        num++;    if (c = = ' + ') {        flag[m] = 1;        res1++;    }    if (c = = '-' && flag[m] = = 0) {        res2++;    }    if (c = = '-' && flag[m] = = 1) {        flag[m] = 0;        res1--;    } Res2 = Max (res1, res2);} printf ("%d", res2); return 0;}

  

D-berland National Library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.