CF1159A.A pile of stones

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya has a pile, that consists of some number of stones. nn times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.

You are given nn operations which Vasya has made. Find the minimal possible number of stones that can be in the pile after making these operations.

输入格式

The first line contains one positive integer nn — the number of operations, that have been made by Vasya ( 1n1001 \leq n \leq 100 ).

The next line contains the string ss , consisting of nn symbols, equal to "-" (without quotes) or "+" (without quotes). If Vasya took the stone on ii -th operation, sis_i is equal to "-" (without quotes), if added, sis_i is equal to "+" (without quotes).

输出格式

Print one integer — the minimal possible number of stones that can be in the pile after these nn operations.

输入输出样例

  • 输入#1

    3
    ---
    

    输出#1

    0
  • 输入#2

    4
    ++++
    

    输出#2

    4
  • 输入#3

    2
    -+
    

    输出#3

    1
  • 输入#4

    5
    ++-++
    

    输出#4

    3

说明/提示

In the first test, if Vasya had 33 stones in the pile at the beginning, after making operations the number of stones will be equal to 00 . It is impossible to have less number of piles, so the answer is 00 . Please notice, that the number of stones at the beginning can't be less, than 33 , because in this case, Vasya won't be able to take a stone on some operation (the pile will be empty).

In the second test, if Vasya had 00 stones in the pile at the beginning, after making operations the number of stones will be equal to 44 . It is impossible to have less number of piles because after making 44 operations the number of stones in the pile increases on 44 stones. So, the answer is 44 .

In the third test, if Vasya had 11 stone in the pile at the beginning, after making operations the number of stones will be equal to 11 . It can be proved, that it is impossible to have less number of stones after making the operations.

In the fourth test, if Vasya had 00 stones in the pile at the beginning, after making operations the number of stones will be equal to 33 .

首页