#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  string s;
  cin >> s;
  long long ans = 0;
  std::stack<char> v;
  long long n = s.size();
  long long yo = 0;
  for (long long int i = 0; i < n; i++) {
    if (s[i] == '[' || s[i] == '(' || s[i] == '{' || s[i] == '<')
      yo++;
    else
      yo--;
  }
  if (yo != 0) return cout << "Impossible\n", 0;
  for (long long int i = 0; i < n; i++) {
    if (s[i] == '[' || s[i] == '(' || s[i] == '{' || s[i] == '<')
      v.push(s[i]);
    else {
      if (v.empty()) return cout << "Impossible\n", 0;
      char x = v.top();
      if (s[i] == ']') {
        if (x != '[') ans++;
        v.pop();
      } else if (s[i] == '>') {
        if (x != '<') ans++;
        v.pop();
      } else if (s[i] == ')') {
        if (x != '(') ans++;
        v.pop();
      } else if (s[i] == '}') {
        if (x != '{') ans++;
        v.pop();
      }
    }
  }
  cout << ans;
}
