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