#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int n = s.length();
  s = ' ' + s;
  stack<char> st;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (st.empty() || s[i] == '{' || s[i] == '(' || s[i] == '[' ||
        s[i] == '<') {
      st.push(s[i]);
      continue;
    } else {
      char ch = st.top();
      if (ch == '{' || ch == '(' || ch == '[' || ch == '<') {
        if ((ch == '{' && s[i] == '}') || (ch == '(' && s[i] == ')') ||
            (ch == '[' && s[i] == ']') || (ch == '<' && s[i] == '>'))
          ;
        else
          ans++;
        st.pop();
      } else
        st.push(s[i]);
    }
  }
  if (!st.empty()) {
    puts("Impossible");
    return;
  }
  printf("%d", ans);
}
int main() {
  solve();
  return 0;
}
