#include <bits/stdc++.h>
using namespace std;
bool isOpen(char c) {
  if (c == '(' || c == '{' || c == '<' || c == '[') return true;
  return false;
}
bool isMatch(char o, char c) {
  if ((o == '(' && c == ')') || (o == '{' && c == '}') ||
      (o == '<' && c == '>') || (o == '[' && c == ']'))
    return true;
  return false;
}
int main() {
  string s;
  cin >> s;
  stack<char> stk;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (isOpen(s[i]))
      stk.push(s[i]);
    else {
      if (stk.empty()) {
        cout << "Impossible";
        return 0;
      } else if (isMatch(stk.top(), s[i]))
        stk.pop();
      else {
        cnt++;
        stk.pop();
      }
    }
  }
  if (!stk.empty())
    cout << "Impossible";
  else
    cout << cnt;
}
