#include <bits/stdc++.h>
using namespace std;
bool isopen(char c) { return (c == '(' || c == '[' || c == '<' || c == '{'); }
bool differ(char op, char cl) {
  switch (op) {
    case '(':
      return cl != ')';
    case '[':
      return cl != ']';
    case '<':
      return cl != '>';
    case '{':
      return cl != '}';
  }
}
int main() {
  string str;
  cin >> str;
  stack<char> open;
  int ans = 0;
  for (int i = 0; str[i]; i++) {
    if (isopen(str[i]))
      open.push(str[i]);
    else {
      if (open.empty())
        return cout << "Impossible", 0;
      else if (differ(open.top(), str[i]))
        ans++;
      open.pop();
    }
  }
  if (!open.empty())
    cout << "Impossible";
  else
    cout << ans;
  return 0;
}
