Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	S := io.NextLine()
	cnt := 0
	for _, s := range S {
		if s == '(' {
			cnt++
		} else if s == ')' {
			cnt--
		} else {
			io.Println(cnt)
			break
		}
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
char s[N];
int top,st[N],ps;
vector<PII> ans;
int main() {
	scanf("%s",s);
	int n=strlen(s);
	for (int i=0;i<n;i++) {
		if (s[i]=='(') {
			st[top++]=i;
		} else if (s[i]==')') {
			if (top>0) {
				ans.pb(mp(st[top-1],i));
				--top;
			}
		} else {
			if (s[i]=='*') ps=i;
		}
	}
	int c=0;
	for (auto p:ans) if (p.fi<ps&&p.se>ps) c++;
	printf("%d\n",c);
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == '('){
      ans++;
    }
    if (S[i] == ')'){
      ans--;
    }
    if (S[i] == '*'){
      cout << ans << endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int t = 0;
  for (char c : s) {
    if (c == '*') {
      cout << t << '\n';
      return 0;
    }
    if (c == '(') {
      ++t;
    } else {
      --t;
    }
  }
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll,ll> pll;

int main(){
    string s;
    int ans=0;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='*'){
            cout<<ans<<endl;
            break;
        }
        else if(s[i]=='(')ans++;
        else ans--;
    }
}

C++: #include<iostream>
#include<string>
#include<stack>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    stack<char> s1, s2;
    bool is_exist = false;
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '*') is_exist = true;
        else if (S[i] == '(') {
            if (is_exist) s2.push(S[i]);
            else s1.push(S[i]);
        }
        else {
            if (s2.empty()) {
                s1.pop();
                if (is_exist) ans++;
            }
            else s2.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n=s.size();
	int a=0;
	for(int i=0;i<n;i++){
		if(s[i]=='(')a++;
		else if(s[i]==')')a--;
		else cout << a << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    string s;
    cin >>s;
    int n = s.size();

    int star = -1;
    rep(i,n)if(s[i]=='*') star = i;

    int ans = 0;
    stack<int> st;
    rep(i,n){
        if(s[i]=='*') continue;

        if(s[i]=='(') st.push(i);
        else{
            int l = st.top();
            st.pop();
            ans += (l<star && star<i);
        }
    }
    cout << ans << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S;cin>>S;
        int now=0;
        
        for(int i=0;i<S.size();i++){
            if(S[i]=='(') now++;
            else if(S[i]==')') now--;
            else if(S[i]=='*'){
                cout<<now<<endl;
                return 0;
            }
        }
    }
}

C++: #pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
string s;
cin>>s;
int n=s.size();
 int l=0;
for(int i=0;i<n;i++){
  if(s[i]=='(')l++;
  else if(s[i]==')')l--;
  else{
    cout<<l<<"\n";
    return 0;
  }
}
}