#include <bits/stdc++.h>
using namespace std;
char arr[1000000 + 10];
int main() {
  while (cin >> arr) {
    int l;
    int num = 0;
    int flag = 1;
    l = strlen(arr);
    int zuo = 0;
    int you = 0;
    stack<char> sta;
    for (int i = 0; i < l; i++) {
      if (arr[i] == '(' || arr[i] == '{' || arr[i] == '[' || arr[i] == '<') {
        sta.push(arr[i]);
        zuo++;
      } else {
        you++;
        if (!sta.empty()) {
          if (sta.top() == '(' && arr[i] == ')' ||
              sta.top() == '{' && arr[i] == '}' ||
              sta.top() == '[' && arr[i] == ']' ||
              sta.top() == '<' && arr[i] == '>')
            sta.pop();
          else {
            sta.pop();
            num++;
          }
        } else
          flag = 0;
      }
    }
    if (flag && zuo == you)
      cout << num << endl;
    else
      cout << "Impossible" << endl;
  }
  return 0;
}
