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