#include <bits/stdc++.h>
using namespace std;
int res;
string s;
vector<int> opens;
map<char, char> m;
int main() {
  m.insert(make_pair('(', ')'));
  m.insert(make_pair('[', ']'));
  m.insert(make_pair('{', '}'));
  m.insert(make_pair('<', '>'));
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(' or s[i] == '[' or s[i] == '{' or s[i] == '<')
      opens.push_back(s[i]);
    else if (!opens.empty() and m[opens.back()] == s[i])
      opens.pop_back();
    else if (opens.empty()) {
      cout << "Impossible";
      return 0;
    } else {
      opens.pop_back();
      res++;
    }
  }
  if (!opens.empty()) {
    cout << "Impossible";
    return 0;
  }
  cout << res;
}
