#include <bits/stdc++.h>
using namespace std;
char c;
int name;
stack<char> s;
bool check1(char ch) {
  return (ch == '[' || ch == '<' || ch == '{' || ch == '(');
}
bool check2(char ch) {
  return (ch == ']' || ch == '>' || ch == '}' || ch == ')');
}
int main() {
  int ans = 0;
  while (scanf("%c", &c) != EOF) {
    if (!check1(c) && !check2(c)) break;
    if (check1(c))
      s.push(c);
    else {
      if (s.empty()) {
        printf("Impossible");
        return 0;
      }
      char top = s.top();
      s.pop();
      if (top == '(' && c != ')')
        ans++;
      else if (top == '{' && c != '}')
        ans++;
      else if (top == '<' && c != '>')
        ans++;
      else if (top == '[' && c != ']')
        ans++;
    }
  }
  if (!s.empty())
    printf("Impossible");
  else
    printf("%d", ans);
  return 0;
}
