#include <bits/stdc++.h>
using namespace std;
char a[1000010];
char b[1000010];
int main() {
  cin >> a;
  int ind = 0;
  int ans = 0;
  int n = strlen(a);
  for (int i = 0; i < n; i++) {
    if (a[i] == '[' || a[i] == '<' || a[i] == '(' || a[i] == '{') {
      b[ind] = a[i];
      ind++;
    } else {
      ind--;
      if (ind < 0) {
        cout << "Impossible";
        return 0;
      }
      if (b[ind] == '[' && a[i] != ']') {
        ans++;
      } else if (b[ind] == '<' && a[i] != '>')
        ans++;
      else if (b[ind] == '{' && a[i] != '}')
        ans++;
      else if (b[ind] == '(' && a[i] != ')')
        ans++;
    }
  }
  if (ind > 0)
    cout << "Impossible";
  else
    cout << ans;
}
