#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> st;
  int total = 0, flag = 1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<' or s[i] == '[' or s[i] == '{' or s[i] == '(')
      st.push(s[i]);
    else {
      if (st.empty() == true) {
        flag = 0;
        break;
      }
      if ((s[i] == '>' and st.top() == '<') or
          (s[i] == ']' and st.top() == '[') or
          (s[i] == '}' and st.top() == '{') or
          (s[i] == ')' and st.top() == '('))
        ;
      else {
        total++;
      }
      st.pop();
    }
  }
  if (flag and st.empty())
    cout << total << "\n";
  else
    cout << "Impossible\n";
}
