#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 1;
int a[MAXN];
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int x = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') {
      a[cnt] = 0;
      cnt++;
    }
    if (s[i] == '<') {
      a[cnt] = 1;
      cnt++;
    }
    if (s[i] == '{') {
      a[cnt] = 2;
      cnt++;
    }
    if (s[i] == '[') {
      a[cnt] = 3;
      cnt++;
    }
    if (s[i] == ')') {
      cnt--;
      if (a[cnt] != 0) x++;
    }
    if (s[i] == '>') {
      cnt--;
      if (a[cnt] != 1) x++;
    }
    if (s[i] == '}') {
      cnt--;
      if (a[cnt] != 2) x++;
    }
    if (s[i] == ']') {
      cnt--;
      if (a[cnt] != 3) x++;
    }
    if (cnt < 0) {
      cout << "Impossible";
      return 0;
    }
  }
  if (cnt != 0)
    cout << "Impossible";
  else
    cout << x;
}
