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