#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = 4 * atan(1);
const int inf = 1 << 30;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int nCase = 0;
int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return x < 0 ? -1 : 1;
}
template <class T>
inline bool read(T &n) {
  T x = 0, tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
  if (c == EOF) return false;
  if (c == '-') c = getchar(), tmp = -1;
  while (c >= '0' && c <= '9') x *= 10, x += (c - '0'), c = getchar();
  n = x * tmp;
  return true;
}
template <class T>
inline void write(T n) {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  int len = 0, data[20];
  while (n) {
    data[len++] = n % 10;
    n /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
}
long long QMOD(long long x, long long k) {
  long long res = 1LL;
  while (k) {
    if (k & 1) res = res * x % MOD;
    k >>= 1;
    x = x * x % MOD;
  }
  return res;
}
int g(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;
  return 4;
}
char s[1000010];
vector<int> vec;
int main(int argc, const char *argv[]) {
  int cnt = 0;
  scanf("%s", s);
  int size = strlen(s);
  for (int i = 0; i <= size - 1; ++i) {
    int o = g(s[i]);
    if (o < 0)
      vec.push_back(o);
    else {
      if (vec.empty()) {
        puts("Impossible");
        return 0;
      }
      int p = vec.back();
      vec.pop_back();
      if (p + o != 0) cnt++;
    }
  }
  vec.empty() ? cout << cnt << endl : cout << "Impossible" << endl;
  return 0;
}
