#include <bits/stdc++.h>
using namespace std;
string s;
int a[1500000];
vector<int> last;
int ans = 0;
int sk[5];
void func() {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') {
      a[i] = 1;
      continue;
    }
    if (s[i] == '[') {
      a[i] = 2;
      continue;
    }
    if (s[i] == '{') {
      a[i] = 3;
      continue;
    }
    if (s[i] == '<') {
      a[i] = 4;
      continue;
    }
    if (s[i] == ')') {
      a[i] = -1;
      continue;
    }
    if (s[i] == ']') {
      a[i] = -2;
      continue;
    }
    if (s[i] == '}') {
      a[i] = -3;
      continue;
    }
    if (s[i] == '>') {
      a[i] = -4;
      continue;
    }
  }
  return;
}
int main() {
  cin >> s;
  int sum = 0;
  func();
  for (int i = 0; i < s.size(); i++) {
    if (a[i] > 0)
      sum++;
    else
      sum--;
    if (sum < 0) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  if (sum != 0) {
    cout << "Impossible" << endl;
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    if (a[i] > 0) {
      sk[a[i]]++;
      last.push_back(a[i]);
    } else {
      if (sk[-a[i]] > 0 && last[last.size() - 1] == -a[i]) {
        sk[-a[i]]--;
        last.pop_back();
        continue;
      } else {
        ans++;
        last.pop_back();
      }
    }
  }
  cout << ans << endl;
}
