#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define N #define M #define WATCH(x) cout << (#x) << ": " << (x) << endl #define fWATCH(x, y) cout << x << ": " << y << endl #define tWATCH(x, y, z) cout << x << ": " << y << ", " << z << endl #define INFO(x) cout << "[ " << x << " ]\n" #define nINFO(n, x) cout << "[ " << to_string() << ": " << x << " ]\n" #define SUM(vec, fn) accumulate(vec.begin(), vec.end(), 0, fn) template struct Pair { T1 x; T2 y; }; struct Range { int from; int to; }; using Str = string; template using Vec = vector; using StrVec = vector; using nMap = map; template using xMap = map; // #define FOR(from, to, what) for (auto i = from; i < to; i++) { what(i); } // #define FOR(from, to, from2, to2, what) for (auto j = from; j < to; j++) { for (auto i = from; i < to; i++) { what(i, j); } } typedef long int32; typedef unsigned long uint32; typedef long long ll; typedef unsigned long long uint64; #define toS(x) to_string(x) int main() { int n; cin >> n; string brackets; cin >> brackets; char slice[3]; slice[2] = '\0'; int acc = 0; for (size_t i = 0; i < brackets.size() - 1; i++) { slice[0] = brackets[i]; slice[1] = brackets[i + 1]; if (!strcmp(slice, "))") || !strcmp(slice, "()")) { ++acc; } } cout << acc << '\n'; return 0; }