#include <bits/stdc++.h>
using namespace std;
char arr[1000005];
int main() {
  stack<char> mystack;
  int count = 0;
  scanf("%s", arr);
  for (int i = 0; arr[i]; ++i) {
    if (arr[i] == '<' || arr[i] == '(' || arr[i] == '{' || arr[i] == '[')
      mystack.push(arr[i]);
    else {
      if (mystack.empty()) {
        printf("Impossible\n");
        return 0;
      }
      char ch = mystack.top();
      mystack.pop();
      if (arr[i] == '>') {
        if (ch != '<') count++;
      } else if (arr[i] == '}') {
        if (ch != '{') count++;
      } else if (arr[i] == ']') {
        if (ch != '[') count++;
      } else if (arr[i] == ')') {
        if (ch != '(') count++;
      }
    }
  }
  if (!mystack.empty())
    printf("Impossible\n");
  else
    printf("%d\n", count);
  return 0;
}
