#include <bits/stdc++.h>
using namespace std;
int main() {
  stack<char> stk;
  char x;
  int counter = 0;
  while (cin >> x) {
    if (x == '(' || x == '[' || x == '{' || x == '<')
      stk.push(x);
    else if (stk.empty())
      ;
    else {
      if (stk.top() == '(' && x == ')') {
        stk.pop();
        counter += 2;
      } else if (stk.top() == '[' && x == ']') {
        stk.pop();
        counter += 2;
      } else if (stk.top() == '{' && x == '}') {
        stk.pop();
        counter += 2;
      } else if (stk.top() == '<' && x == '>') {
        stk.pop();
        counter += 2;
      } else
        while (!stk.empty()) stk.pop();
    }
  }
  cout << counter << endl;
  return 0;
}
