欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1159A.A pile of stones
A pile of stones
Vasya has a pile, that consists of some number of stones. 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 operations which Vasya has made. Find the minimal possible number of stones that can be in the pile after making these operations.
Input
The first line contains one positive integer — the number of operations, that have been made by Vasya ().
The next line contains the string , consisting of symbols, equal to "-" (without quotes) or "+" (without quotes). If Vasya took the stone on -th operation, is equal to "-" (without quotes), if added, is equal to "+" (without quotes).
Output
Print one integer — the minimal possible number of stones that can be in the pile after these operations.
Note
In the first test, if Vasya had stones in the pile at the beginning, after making operations the number of stones will be equal to . It is impossible to have less number of piles, so the answer is . Please notice, that the number of stones at the beginning can't be less, than , 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 stones in the pile at the beginning, after making operations the number of stones will be equal to . It is impossible to have less number of piles because after making operations the number of stones in the pile increases on stones. So, the answer is .
In the third test, if Vasya had stone in the pile at the beginning, after making operations the number of stones will be equal to . 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 stones in the pile at the beginning, after making operations the number of stones will be equal to .
Samples
3
---
0
4
++++
4
2
-+
1
5
++-++
3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |