#include <bits/stdc++.h>
using namespace std;
char a[1000011];
int main() {
  while (~scanf("%s", a)) {
    int t = strlen(a);
    if (t % 2 != 0)
      printf("Impossible\n");
    else {
      stack<char> sta;
      int ans = 0, p = 0;
      for (int i = 0; i < t; i++) {
        if (a[i] == '{' || a[i] == '[' || a[i] == '(' || a[i] == '<') {
          sta.push(a[i]);
          ans++;
        } else {
          if (sta.empty()) {
            p++;
            printf("Impossible\n");
            break;
          } else {
            char s = sta.top();
            if ((s == '{' && a[i] == '}') || (s == '(' && a[i] == ')') ||
                (s == '[' && a[i] == ']') || (s == '<' && a[i] == '>')) {
              ans--;
            }
            sta.pop();
          }
        }
      }
      if (p == 0) {
        if (sta.empty()) {
          if (ans < 0)
            printf("Impossible\n");
          else
            printf("%d\n", ans);
        } else
          printf("Impossible\n");
      }
    }
    memset(a, 0, sizeof(a));
  }
  return 0;
}
