#include <bits/stdc++.h>
using namespace std;
int main() {
  long long sum = 0;
  stack<char> sol;
  string s;
  cin >> s;
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] == '(' || s[i] == '{' || s[i] == '[' || s[i] == '<') {
      sol.push(s[i]);
    } else if (sol.empty()) {
      cout << "Impossible";
      return 0;
    } else if (s[i] == ')') {
      if (sol.top() == '(')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    } else if (s[i] == '}') {
      if (sol.top() == '{')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    } else if (s[i] == ']') {
      if (sol.top() == '[')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    } else if (s[i] == '>') {
      if (sol.top() == '<')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    }
  }
  if (sol.empty())
    cout << sum;
  else
    cout << "Impossible";
  return 0;
}
