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