#include <bits/stdc++.h>
using namespace std;
char ch[1000006];
int main() {
  int o = 0, c = 0;
  scanf("%s", ch);
  int len = strlen(ch);
  for (int i = 0; i < len; i++) {
    if (ch[i] == '[' || ch[i] == '<' || ch[i] == '(' || ch[i] == '{') {
      o++;
    } else {
      c++;
    }
  }
  if (o != c) {
    cout << "Impossible";
    return 0;
  }
  stack<char> s;
  int ans = 0;
  int flag = 1;
  for (int i = 0; i < len; i++) {
    if (i == 0) {
      if (ch[i] == '[' || ch[i] == '<' || ch[i] == '(' || ch[i] == '{') {
        s.push(ch[i]);
      } else {
        s.push(ch[i]);
        flag = 0;
      }
    } else {
      if (ch[i] == '[' || ch[i] == '<' || ch[i] == '(' || ch[i] == '{') {
        s.push(ch[i]);
      } else {
        if (s.empty()) {
          flag = 0;
          break;
        }
        char temp = s.top();
        s.pop();
        if (ch[i] == ')') {
          if (temp == '(')
            ;
          else
            ans++;
        } else if (ch[i] == '}') {
          if (temp == '{')
            ;
          else
            ans++;
        } else if (ch[i] == ']') {
          if (temp == '[')
            ;
          else
            ans++;
        } else if (ch[i] == '>') {
          if (temp == '<')
            ;
          else
            ans++;
        }
      }
    }
    if (flag == 0) {
      break;
    }
  }
  if (flag == 0) {
    cout << "Impossible";
    return 0;
  }
  cout << ans;
  return 0;
}
