#include <bits/stdc++.h>
using namespace std;
int main() {
  int cn = 0;
  string s;
  cin >> s;
  vector<char> v;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') v.push_back('(');
    if (s[i] == '{') v.push_back('{');
    if (s[i] == '<') v.push_back('<');
    if (s[i] == '[') v.push_back('[');
    if (s[i] == ')') {
      if (v.empty()) {
        v.push_back('1');
        break;
      }
      if (v.back() != '(') cn++;
      v.pop_back();
    }
    if (s[i] == '}') {
      if (v.empty()) {
        v.push_back('1');
        break;
      }
      if (v.back() != '{') cn++;
      v.pop_back();
    }
    if (s[i] == '>') {
      if (v.empty()) {
        v.push_back('1');
        break;
      }
      if (v.back() != '<') cn++;
      v.pop_back();
    }
    if (s[i] == ']') {
      if (v.empty()) {
        v.push_back('1');
        break;
      }
      if (v.back() != '[') cn++;
      v.pop_back();
    }
  }
  if (v.empty())
    cout << cn;
  else
    puts("Impossible");
}
