#include <bits/stdc++.h>
using namespace std;
bool match(char t1, char t2) {
  if ((t1 == '<' && t2 == '>') || (t1 == '(' && t2 == ')') ||
      (t1 == '[' && t2 == ']') || (t1 == '{' && t2 == '}'))
    return true;
  return false;
}
int main() {
  string s;
  cin >> s;
  stack<char> st;
  int res = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '<' || s[i] == '(' || s[i] == '[' || s[i] == '{')
      st.push(s[i]);
    else {
      if (st.empty()) {
        cout << "Impossible" << endl;
        return 0;
      }
      char t = st.top();
      if (!match(t, s[i])) ++res;
      st.pop();
    }
  }
  if (!st.empty()) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << res << endl;
  return 0;
}
