#include <bits/stdc++.h>
using namespace std;
int main() {
  int r = 0, x, y;
  r = 0;
  stack<int> s;
  char c;
  while (cin.get(c)) {
    switch (c) {
      case '[':
        x = -1;
        break;
      case ']':
        x = 1;
        break;
      case '{':
        x = -2;
        break;
      case '}':
        x = 2;
        break;
      case '(':
        x = -3;
        break;
      case ')':
        x = 3;
        break;
      case '<':
        x = -4;
        break;
      case '>':
        x = 4;
        break;
      default:
        continue;
    }
    if (s.size() > 0) {
      y = s.top();
      if (y > 0 || x < 0) {
        s.push(x);
        continue;
      }
      s.pop();
      if (x + y != 0) r++;
    } else
      s.push(x);
  }
  if (s.size() > 0)
    cout << "Impossible";
  else
    cout << r << endl << flush;
  return 0;
}
