#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> stk;
  int count = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '(' || s[i] == '{' || s[i] == '[' || s[i] == '<') {
      stk.push(s[i]);
    } else if (s[i] == ')' || s[i] == '}' || s[i] == ']' || s[i] == '>') {
      if (stk.empty()) {
        cout << "Impossible" << endl;
        return 0;
      }
      char tp = stk.top();
      stk.pop();
      if (!((tp == '(' && s[i] == ')') || (tp == '{' && s[i] == '}') ||
            (tp == '[' && s[i] == ']') || (tp == '<' && s[i] == '>')))
        count++;
    }
  }
  if (!stk.empty()) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << count << endl;
  return 0;
}
