#include <bits/stdc++.h>
using namespace std;
int main() {
  stack<char> e;
  string c;
  cin >> c;
  int f = 0;
  for (int i = 0; i < c.size(); i++) {
    if (c[i] == '(' || c[i] == '<' || c[i] == '{' || c[i] == '[') e.push('(');
    if ((c[i] == ')' || c[i] == '>' || c[i] == '}' || c[i] == ']') &&
        e.size() != 0) {
      e.pop();
      f++;
    }
  }
  if (f * 2 != c.size())
    cout << "Impossible" << endl;
  else {
    f = 0;
    for (int i = 0; i < c.size(); i++) {
      if (c[i] == '(' || c[i] == '<' || c[i] == '{' || c[i] == '[')
        e.push(c[i]);
      if (c[i] == ')' || c[i] == '>' || c[i] == '}' || c[i] == ']') {
        if (c[i] == ')' && e.top() != '(')
          f++;
        else if (c[i] == '>' && e.top() != '<')
          f++;
        else if (c[i] == ']' && e.top() != '[')
          f++;
        else if (c[i] == '}' && e.top() != '{')
          f++;
        e.pop();
      }
    }
    cout << f << endl;
  }
  return 0;
}
