#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  stack<char> s;
  map<char, char> type = {{'(', ')'}, {'{', '}'}, {'<', '>'}, {'[', ']'}};
  int ans = 0;
  for (auto it : str) {
    if (it == '{' || it == '(' || it == '<' || it == '[') {
      s.push(it);
    } else {
      if (s.empty()) {
        cout << "Impossible\n";
        return 0;
      } else {
        if (type[s.top()] != it) {
          ans += 1;
        }
        s.pop();
      }
    }
  }
  if (s.empty()) {
    cout << ans << "\n";
    return 0;
  }
  cout << "Impossible\n";
  return 0;
}
