#include <bits/stdc++.h>
using namespace std;
bool isopen(char c) { return (c == '{' || c == '[' || c == '<' || c == '('); }
char mirror(char c) {
  if (c == '}') return '{';
  if (c == ']') return '[';
  if (c == '>') return '<';
  if (c == ')') return '(';
  if (c == '{') return '}';
  if (c == '[') return ']';
  if (c == '<') return '>';
  if (c == '(') return ')';
}
char ch[1000001];
int ans;
string s;
int main() {
  cin >> s;
  int k = 0;
  if (s.length() % 2) return cout << "Impossible", 0;
  for (int i = 0; i < s.length(); i++) {
    if (isopen(s[i])) {
      k++;
      ch[k] = s[i];
    } else {
      k--;
      if (k < 0) {
        return cout << "Impossible", 0;
      }
      if (ch[k + 1] != mirror(s[i])) ans++;
    }
  }
  if (k != 0) return cout << "Impossible", 0;
  cout << ans;
  return 0;
}
