#include <bits/stdc++.h>
using namespace std;
long long n, m, i;
stack<char> st;
char c;
string s;
int main() {
  cin >> s;
  for (i = 0; s[i]; i++) {
    if (st.size() == 0 || s[i] == '<' || s[i] == '(' || s[i] == '[' ||
        s[i] == '{')
      st.push(s[i]);
    else {
      c = st.top();
      if (c == '}' || c == ']' || c == '>' || c == ')') {
        cout << "Impossible";
        return 0;
      }
      st.pop();
      if ((c == '[' && s[i] == ']') || (c == '(' && s[i] == ')') ||
          (c == '{' && s[i] == '}') || (c == '<' && s[i] == '>'))
        continue;
      else
        m++;
    }
  }
  if (st.size() > 0)
    cout << "Impossible";
  else
    cout << m;
}
