#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  vector<char> v;
  long long k = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '(' || s[i] == '[' || s[i] == '{' || s[i] == '<') {
      v.push_back(s[i]);
    } else {
      if (v.empty()) {
        cout << "Impossible";
        return;
      }
      if (s[i] == ')' && v.back() != '(') {
        k++;
      }
      if (s[i] == '}' && v.back() != '{') {
        k++;
      }
      if (s[i] == ']' && v.back() != '[') {
        k++;
      }
      if (s[i] == '>' && v.back() != '<') {
        k++;
      }
      v.pop_back();
    }
  }
  if (v.size()) {
    cout << "Impossible";
    return;
  }
  cout << k;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
