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++: /*  -*- coding: utf-8 -*-
 *
 * 2845.cc: Star in Parentheses
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  int cnt = 0;
  for (char *cpt = s; *cpt != '*'; cpt++) {
    if (*cpt == '(') cnt++;
    else cnt--;
  }

  printf("%d\n", cnt);
  return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

int main() {
    string S;
    cin >> S;

    int ans = 0;
    for (char c : S) {
        if (c == '*') break;
        ans += (c == '(' ? 1 : -1);
    }

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

C++: #include <cstdio>
#include <cctype>
#include <cassert>
#include <string>

int parse(const std::string& s, size_t& i) {
  if (s[i] == '*') {
    ++i;
    return 0;
  }

  assert(s[i] == '(');
  ++i;
  int res = 0;
  while (s[i] != ')') {
    if (s[i] == '*') {
      res = 1;
      ++i;
    } else {
      int tmp = parse(s, i);
      if (tmp) res += ++tmp;
    }
  }
  assert(s[i] == ')');
  ++i;
  return res;
}

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s = buf;
  size_t i = 0;

  while (i != s.length()) {
    int res = parse(s, i);
    if (res) return !printf("%d\n", res);
  }
  puts("0");
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    int star = -1;
    REP(i, 0, n) {
        if (s[i] == '*') {
            star = i;
        }
    }
    {
        int depth = 0;
        for (int i = star; i >= 0; i--) {
            if (s[i] == '(') {
                depth++;
            }
            if (s[i] == ')') {
                depth--;
            }
            ans = max(ans, depth);
        }
    }
    {
        int depth = 0;
        for (int i = star; i < n; i++) {
            if (s[i] == ')') {
                depth++;
            }
            if (s[i] == '(') {
                depth--;
            }
            ans = max(ans, depth);
        }
    }
    cout << ans << endl;
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){
  
  string s;
  cin >> s;

  int len = s.length();
  int d = 0;
  REP(i,len){
    if(s[i] == '*'){
     cout << d << endl;
     break;
    }else if(s[i] == '('){
      d++;
    }else{
      d--;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 600000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000 大きいとワ―シャルフロイドでオーバーフローを起こす
#define PI 3.14159265358979

//.size()はunsignedなので0-1でオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

long long int dy[5] = { 0,0,1,-1,0 };
long long int dx[5] = { 1,-1,0,0,0 };


int main(void) {

	int right = 0;
	int left = 0;
	bool check = false;
	string s;

	cin >> s;

	FOR(i, 0, s.size() - 1) {
		if (s[i] == '*') {
			check = true;
			continue;
		}
		if (check == false) {
			if (s[i] == '(') {
				left++;
			}
			else {
				if (left > 0) {
					left--;
				}
			}
		}
		if (check == true) {
			if (s[i] == ')') {
				right++;
			}
			else {
				right--;
			}
		}
	}



	cout << max(0,min(left,right)) << endl;

}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	char buf[200];

	scanf("%s",buf);

	int ans = 0;

	for(int i = 0; buf[i] != '*'; i++){
		if(buf[i] == '('){
			ans++;
		}else{ //buf[i] == ')'
			ans--;
		}
	}

	printf("%d\n",ans);

	return 0;
}