#include <bits/stdc++.h>
using namespace std;
char closing(char c) {
  if (c == '(') return ')';
  if (c == '[') return ']';
  if (c == '{') return '}';
  if (c == '<') return '>';
}
int main() {
  std::string s;
  std::vector<char> v;
  int x = 0;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '<' || s[i] == '[' || s[i] == '{' || s[i] == '(')
      v.push_back(s[i]);
    else if (v.empty()) {
      cout << "Impossible";
      return 0;
    } else if (s[i] == closing(v[v.size() - 1]))
      v.pop_back();
    else {
      v.pop_back();
      x++;
    }
  }
  if (v.empty())
    cout << x;
  else
    cout << "Impossible";
  return 0;
}
