#include <bits/stdc++.h>
using namespace std;
char str[2000005];
int getID(char c) {
  if (c == '<') return 1;
  if (c == '{') return 2;
  if (c == '[') return 3;
  if (c == '(') return 4;
  if (c == '>') return -1;
  if (c == '}') return -2;
  if (c == ']') return -3;
  if (c == ')') return -4;
  return 0;
}
int st[2000005];
int stop = 0;
int main() {
  scanf("%s", str);
  bool flag = true;
  int change = 0;
  for (int i = 0; str[i] && flag; i++) {
    int id = getID(str[i]);
    if (id > 0) {
      st[stop++] = id;
    } else {
      if (stop <= 0)
        flag = false;
      else {
        int ele = st[--stop];
        if (ele != -id) change++;
      }
    }
  }
  flag = (flag && stop == 0);
  if (!flag)
    puts("Impossible");
  else
    printf("%d\n", change);
  return 0;
}
