#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int main() {
  int admit = 0;
  int oBlock = 0, cBlock = 0;
  stack<char> stack1;
  int ans = 0;
  for (char c = getchar(); c != '\n';) {
    if (c == '<' || c == '(' || c == '[' || c == '{') {
      admit++;
      switch (c) {
        case '<': {
          stack1.push('>');
          break;
        }
        case '(': {
          stack1.push(')');
          break;
        }
        case '[': {
          stack1.push(']');
          break;
        }
        case '{': {
          stack1.push('}');
          break;
        }
      }
    } else {
      admit--;
      if (admit < 0) {
        cout << "Impossible" << endl;
        return 0;
      }
      if (c != stack1.top()) ans++;
      stack1.pop();
    }
    c = getchar();
  }
  if (admit != 0) {
    cout << "Impossible" << endl;
    return 0;
  }
  printf("%d", ans);
  return 0;
}
