#include using namespace std; #define rep(i , a, b) for(int i = a; i < (b) ; ++i) #define all(x) std::begin(x), std::end(x) #define sz(x) ((int) x.size()) typedef long long ll; #define int ll typedef pair pii; typedef vector vi; signed main() { cin.tie(0)->sync_with_stdio(0); int n; int res = 0; cin >> n; for (int i = 0; i < n; ++i) { char sym; cin >> sym; res += sym == ')'; } cout << res << endl; return 0; }