#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  string s;
  cin >> s;
  stack<char> st;
  int ans = 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;
      }
      if (s[i] - st.top() != 1 && s[i] - st.top() != 2) {
        ans++;
      }
      st.pop();
    }
  }
  if (!st.empty())
    cout << "Impossible";
  else
    cout << ans;
  return 0;
}
