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