#include <bits/stdc++.h>
using namespace std;
stack<char> ss;
bool samechar(char a, char b) {
  if (a == '[' && b == ']') return true;
  if (a == '<' && b == '>') return true;
  if (a == '{' && b == '}') return true;
  if (a == '(' && b == ')') return true;
  return false;
}
int main() {
  string str;
  cin >> str;
  int ans = 0;
  int n = str.length();
  for (int i = 0; i < n; i++) {
    if (str[i] == '(' || str[i] == '[' || str[i] == '<' || str[i] == '{') {
      ss.push(str[i]);
      continue;
    }
    if (ss.size() == 0) {
      cout << "Impossible" << endl;
      return 0;
    }
    char z = ss.top();
    if (!samechar(z, str[i])) {
      ans++;
    }
    ss.pop();
  }
  if (ss.size() != 0) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << ans << endl;
}
