#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  string s;
  cin >> s;
  stack<char> stk;
  for (char c : s)
    if (c == '[' || c == '(' || c == '{' || c == '<')
      stk.push(c);
    else {
      if (stk.size() == 0) {
        cout << "Impossible";
        return 0;
      }
      if (c == ']' && stk.top() != '[')
        ans++;
      else if (c == '}' && stk.top() != '{')
        ans++;
      else if (c == '>' && stk.top() != '<')
        ans++;
      else if (c == ')' && stk.top() != '(')
        ans++;
      stk.pop();
    }
  cout << (stk.size() != 0 ? "Impossible" : to_string(ans));
}
