#include <bits/stdc++.h>
using namespace std;
string s;
long long i, k, k1, k2, k3, k4;
vector<char> v;
int main() {
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '<' || s[i] == '{' || s[i] == '[' || s[i] == '(')
      v.push_back(s[i]);
    else {
      if (v.size() == 0) {
        cout << "Impossible";
        return 0;
      } else {
        if ((s[i] == ')' && v[v.size() - 1] != '(')) k++;
        if ((s[i] == '}' && v[v.size() - 1] != '{')) k++;
        if ((s[i] == ']' && v[v.size() - 1] != '[')) k++;
        if ((s[i] == '>' && v[v.size() - 1] != '<')) k++;
        v.pop_back();
      }
    }
  }
  if (v.size() > 0)
    cout << "Impossible";
  else
    cout << k;
  return 0;
}
