#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
template <typename t1>
t1 gcd(t1 a, t1 b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename t1>
t1 lcm(t1 a, t1 b) {
  return a * (b / gcd(a, b));
}
int main() {
  string s;
  while (cin >> s) {
    stack<char> st;
    int len = s.length();
    int count = 0;
    int flag = 0;
    for (int i = 0; i < len; i++) {
      char x = s[i];
      if (x == '<' || x == '(' || x == '{' || x == '[') {
        st.push(x);
      } else {
        if (st.empty()) {
          flag = 1;
          break;
        }
        char y = st.top();
        if (y == '<' && x == '>') {
          st.pop();
        } else if (y == '(' && x == ')') {
          st.pop();
        } else if (y == '[' && x == ']') {
          st.pop();
        } else if (y == '{' && x == '}') {
          st.pop();
        } else {
          count++;
          st.pop();
        }
      }
    }
    if (!st.empty()) flag = 1;
    if (flag)
      cout << "Impossible" << endl;
    else
      cout << count << endl;
  }
}
