#include #include #include #include #include #include #include #include #include namespace ranges = std::ranges; namespace views = std::views; // #include "Src/Number/IntegerDivision.hpp" // #include "Src/Utility/BinarySearch.hpp" // #include "Src/Sequence/CompressedSequence.hpp" // #include "Src/Sequence/RunLengthEncoding.hpp" // #include "Src/Algebra/Group/AdditiveGroup.hpp" // #include "Src/DataStructure/FenwickTree/FenwickTree.hpp" // #include "Src/DataStructure/SegmentTree/SegmentTree.hpp" // #include "Src/DataStructure/DisjointSetUnion/DisjointSetUnion.hpp" // using namespace zawa; // #include "atcoder/modint" // using mint = atcoder::modint998244353; using namespace std; int N; string S; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin >> N >> S; vector dp(2, -1); dp[0] = 0; for (char c : S) { vector next = dp; if (c == '-') next[0] = dp[0] + 1; else if (c == '0') next[1] = max(dp[1], dp[0] + 1); else if (c == '+') next[1] = max(dp[0], dp[1]) + 1; dp = move(next); } cout << *ranges::max_element(dp) << '\n'; }