#include <bits/stdc++.h>
struct stack {
  char a[1000010];
  int top;
} st;
void push(char val) { st.a[st.top++] = val; }
int pop() { return st.a[--st.top]; }
int empty() { return st.top == 0; }
char s[1000010];
int main() {
  char t;
  int i, cnt = 0;
  gets(s);
  st.top = 0;
  for (i = 0; s[i]; i++) {
    if (s[i] == '[' || s[i] == '<' || s[i] == '(' || s[i] == '{')
      push(s[i]);
    else {
      if (empty()) {
        printf("Impossible");
        return 0;
      }
      t = pop();
      if (t == '(' && s[i] != ')' || t == '<' && s[i] != '>' ||
          t == '[' && s[i] != ']' || t == '{' && s[i] != '}')
        cnt++;
    }
  }
  if (!empty()) {
    printf("Impossible");
    return 0;
  }
  printf("%d", cnt);
  return 0;
}
