#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
inline long long int sqr(long long int x) { return x * x; }
map<char, long long int> M, Mn;
stack<long long int> S;
long long int A[300003], C[300003], dp[103];
long long int one, zero, ansR, numNodes;
int main() {
  long long int T, i, j, h, l, r, k, s, a, b, c, d, n, m, w, x, y, v, z, t, p,
      q, curr, prev, sum, ans, pos, val, countA, secondMin, indicator;
  string P;
  cin >> P;
  n = P.size();
  M['<'] = 1;
  M['{'] = 2;
  M['['] = 3;
  M['('] = 4;
  M['>'] = -1;
  M['}'] = -2;
  M[']'] = -3;
  M[')'] = -4;
  countA = 0;
  for (long long int i = (0); i <= (n - 1); ++i) {
    t = M[P[i]];
    if (S.size() == 0) {
      if (t < 0) {
        printf("Impossible\n");
        return 0;
      } else
        S.push(t);
    } else if (t > 0)
      S.push(t);
    else {
      k = S.top();
      if (k + t != 0) countA++;
      S.pop();
    }
  }
  if (S.size() != 0)
    printf("Impossible\n");
  else
    printf("%lld\n", countA);
  return 0;
}
