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