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