#include <bits/stdc++.h>
using namespace std;
stack<char> s;
string str;
map<char, int> mp1, mp2;
int main() {
  int i, j;
  int cnt = 0;
  int flag = 0;
  mp1['['] = mp2[']'] = 0;
  mp1['('] = mp2[')'] = 1;
  mp1['{'] = mp2['}'] = 2;
  mp1['<'] = mp2['>'] = 3;
  cin >> str;
  for (i = 0; i < str.size(); i++) {
    if (str[i] == '[' || str[i] == '(' || str[i] == '{' || str[i] == '<') {
      s.push(str[i]);
    } else {
      if (s.empty()) {
        flag = 1;
        break;
      } else {
        if (mp1[s.top()] != mp2[str[i]]) cnt++;
        s.pop();
      }
    }
  }
  if (!s.empty()) flag = 1;
  if (flag)
    printf("Impossible\n");
  else
    printf("%d\n", cnt);
  return 0;
}
