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