#include <bits/stdc++.h>
using namespace std;
string s;
char v[1000005];
int o, a, n;
int main() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    char c = s[i];
    if (c == '(' || c == '[' || c == '<' || c == '{')
      a++;
    else
      a--;
    if (a < 0) a = -123456;
  }
  if (a) {
    printf("Impossible\n");
    return 0;
  }
  for (int i = 0; i < n; i++) {
    char c = s[i];
    if (c == '<' || c == '{' || c == '(' || c == '[') {
      v[++o] = c;
      continue;
    }
    if (c == '}')
      c = '{';
    else if (c == '>')
      c = '<';
    else if (c == ')')
      c = '(';
    else
      c = '[';
    if (v[o--] != c) a++;
  }
  printf("%d\n", a);
  return 0;
}
