#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int main() {
  stack<char> st;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '[' || s[i] == '<' || s[i] == '{' || s[i] == '(')
      st.push(s[i]);
    else {
      if (st.size() == 0) return cout << "Impossible", 0;
      char x;
      if (st.top() == '(')
        x = st.top() + 1;
      else
        x = st.top() + 2;
      if (x != s[i]) ans++;
      st.pop();
    }
  }
  if (st.size() != 0) return cout << "Impossible", 0;
  cout << ans;
  return 0;
}
