#include <bits/stdc++.h>
using namespace std;
stack<char> rbs;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int(i) = 0; (i) < ((int)(s.size())); (i)++) {
    if (s[i] == '<' or s[i] == '{' or s[i] == '(' or s[i] == '[')
      rbs.push(s[i]);
    else {
      if (rbs.empty()) {
        ans = -1;
        break;
      }
      char c = rbs.top();
      rbs.pop();
      if ((c == '{' and s[i] != '}') or (c == '<' and s[i] != '>') or
          (c == '(' and s[i] != ')') or (c == '[' and s[i] != ']'))
        ans += 1;
    }
  }
  if (ans != -1 and rbs.empty())
    printf("%d\n", ans);
  else
    printf("Impossible");
  return 0;
}
