#include <bits/stdc++.h>
using namespace std;
stack<char> a;
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  int k = 0;
  bool f = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<' or s[i] == '(' or s[i] == '{' or s[i] == '[')
      a.push(s[i]);
    else {
      char q;
      if (a.empty()) {
        f = 1;
        break;
      }
      q = a.top();
      a.pop();
      if (s[i] == '>' and q != '<')
        k++;
      else if (s[i] == ')' and q != '(')
        k++;
      else if (s[i] == '}' and q != '{')
        k++;
      else if (s[i] == ']' and q != '[')
        k++;
    }
  }
  if (f == 1 or !a.empty())
    cout << "Impossible";
  else
    cout << k;
  return 0;
}
