#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) { return (a < b) ? a : b; }
int max(int a, int b) { return (a > b) ? a : b; }
int main() {
  int k = 0;
  char tmp;
  stack<char> c;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    tmp = s[i];
    if ((tmp == '{') || (tmp == '(') || (tmp == '[') || (tmp == '<')) {
      c.push(tmp);
      continue;
    }
    if (c.empty() == true) {
      cout << "Impossible";
      return 0;
    }
    if (tmp == '}') {
      if (c.top() != '{') k++;
      c.pop();
    }
    if (tmp == ')') {
      if (c.top() != '(') k++;
      c.pop();
    }
    if (tmp == ']') {
      if (c.top() != '[') k++;
      c.pop();
    }
    if (tmp == '>') {
      if (c.top() != '<') k++;
      c.pop();
    }
  }
  if (c.empty() == false)
    cout << "Impossible";
  else
    cout << k;
  return 0;
}
