#include <bits/stdc++.h>
using namespace std;
bool ch(char x, char y) {
  if (x == '{' && y == '}' || x == '[' && y == ']' || x == '<' && y == '>' ||
      x == '(' && y == ')')
    return 1;
  return 0;
}
int main() {
  string s;
  cin >> s;
  vector<char> open = {'(', '{', '[', '<'};
  vector<char> close = {')', '}', ']', '>'};
  int r = 0;
  for (int i = 0; i < s.size(); i++) {
    if ((find(open.begin(), open.end(), s[i]) == open.end())) {
      r--;
    } else {
      r++;
    }
    if (r < 0) {
      cout << "Impossible";
      return 0;
    }
  }
  if (r) {
    cout << "Impossible";
    return 0;
  }
  int ans = 0;
  vector<char> v;
  for (int i = 0; i < s.size(); i++) {
    if (find(open.begin(), open.end(), s[i]) != open.end()) {
      v.push_back(s[i]);
    } else {
      if (!ch(v.back(), s[i])) {
        ans++;
      }
      v.pop_back();
    }
  }
  cout << ans;
  return 0;
}
