#include <bits/stdc++.h>
using namespace std;
stack<char> k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  long long int cnt = 0;
  for (long long int i = 0; i < s.length(); i++) {
    if (k.empty() || s[i] == '(' || s[i] == '[' || s[i] == '<' || s[i] == '{')
      k.push(s[i]);
    else {
      char ch = k.top();
      if (ch == '(' || ch == '[' || ch == '<' || ch == '{') {
        if ((ch != '(' && s[i] == ')') || (ch != '{' && s[i] == '}') ||
            (ch != '[' && s[i] == ']') || (ch != '<' && s[i] == '>'))
          cnt++;
        k.pop();
      }
    }
  }
  if (k.empty())
    cout << cnt << "\n";
  else
    cout << "Impossible"
         << "\n";
}
