#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main() {
	string S;
	cin >> S;
	int p = 0;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '(') {
			p++;
		}
		else if (S[i] == ')') {
			p--;
		}
		else {
			ans = p;
		}
	}
	cout << ans << endl;
}
