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 int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  int st;
  int N = s.size();
  for ( int i = 0; i < N; i++ ) {
    if ( s[i] == '*' ) st = i;
  }

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    for ( int j = i+1; j < N; j++ ) {
      if ( s[i] != '(' || s[j] != ')' ) continue;
      if ( st < i || j < st ) continue;
      int cnt = 0;
      bool flag = true;
      for ( int k = i+1; k <= j-1; k++ ) {
	if ( s[k] == '*' ) continue;
	if ( s[k] == '(' ) cnt++;
	else cnt--;
	if ( cnt < 0 ) flag = false;
      }
      if ( cnt != 0 ) continue;
      if ( flag ) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
    string s;

    cin >> s;

    int cnt = 0;
    for( int i = 0; i < s.size(); i++ )
    {
        if( s[i] == '(' )
            cnt++;
        else if( s[i] == ')' )
            cnt--;
        else
            break;
    }
    cout << cnt << endl;
    
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 1;
	while (kkt--) {
		string s; cin >> s;
		int cnt = 0;
		ll res = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '(') cnt++;
			if (s[i] == '*') res = cnt;
			if (s[i] == ')') cnt--;
		}
		cout << res << endl;
	}
	return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    string S;
    cin >> S;
    set<P> paren;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] != '(') continue;
        int depth = 1;
        for(int j = i + 1; j < S.size(); j++) {
            if(S[j] == '(') depth++;
            if(S[j] == ')') depth--;
            if(depth == 0) {
                paren.emplace(i, j);
                break;
            }
        }
    }

    int apos;
    for(int i = 0; i < S.size(); i++) if(S[i] == '*') {
        apos = i;
        break;
    }

    int ans = 0;
    for(auto &&ele : paren) {
        int l, r;
        tie(l, r) = ele;
        if(l < apos && apos < r) ans++;
    }

    cout << ans << endl;
    return 0;
}

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

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

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
 
template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}


string del(string& s, int& ans){
	rep(i,s.size() - 2){
		if(s.substr(i, 3) == "(*)"){
			ans++;
			return s.substr(0, i) + '*' + s.substr(i + 3);
		}
	}
	rep(i,s.size() - 1){
		if(s.substr(i, 2) == "()"){
			return s.substr(0, i) + s.substr(i + 2);
		}
	}
	return s;
}


int main(){
	string s;
	while(cin >> s){
		s = '@' + s;
		int ans = 0;
		while(true){
			//show(s)
			string nxt = del(s, ans);
			if(s == nxt){
				break;
			}
			s = nxt;
		}
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    ll now = 0;
    REP(i, n) {
        if(s[i]=='(') now++;
        else if(s[i]== ')') now--;
        else {
            cout << now << endl;
        }
    }

    return 0;
}

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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    stack<char> st;
    for(auto c: s){
        if(c == '(')st.push(c);
        else if(c == ')')st.pop();
        else if(c == '*'){
            cout << st.size() << endl;
            break;
        }
    }

    return 0;
}