#include <bits/stdc++.h>
using namespace std;
int const maxn = 1e6 + 5;
char str[maxn];
int main() {
  stack<int> s;
  while (~scanf("%s", str)) {
    int ans = 0;
    int length = strlen(str);
    for (int i = 0; i < length; i++) {
      if (str[i] == '[')
        s.push(str[i]);
      else if (str[i] == '{')
        s.push(str[i]);
      else if (str[i] == '<')
        s.push(str[i]);
      else if (str[i] == '(')
        s.push(str[i]);
      else if (str[i] == ')') {
        if (!s.empty()) {
          if (s.top() != '(') ans++;
          s.pop();
        } else {
          ans = -1;
          break;
        }
      } else if (str[i] == ']') {
        if (!s.empty()) {
          if (s.top() != '[') ans++;
          s.pop();
        } else {
          ans = -1;
          break;
        }
      } else if (str[i] == '}') {
        if (!s.empty()) {
          if (s.top() != '{') ans++;
          s.pop();
        } else {
          ans = -1;
          break;
        }
      } else if (str[i] == '>') {
        if (!s.empty()) {
          if (s.top() != '<') ans++;
          s.pop();
        } else {
          ans = -1;
          break;
        }
      }
    }
    if (!s.empty()) ans = -1;
    if (ans == -1)
      cout << "Impossible" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
