#include <bits/stdc++.h>
using namespace std;
stack<char> a;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '[' || s[i] == '<' || s[i] == '{' || s[i] == '(') {
      a.push(s[i]);
    } else {
      if (a.size() == 0) {
        cout << "Impossible";
        return 0;
      }
      char x = a.top();
      if (x == '[') {
        x = ']';
      }
      if (x == '{') {
        x = '}';
      }
      if (x == '(') {
        x = ')';
      }
      if (x == '<') {
        x = '>';
      }
      if (s[i] != x) {
        ans++;
      }
      a.pop();
    }
  }
  if (a.size()) {
    cout << "Impossible";
    return 0;
  }
  cout << ans;
  return 0;
}
