#include <bits/stdc++.h>
using namespace std;
int a[1000001], b[1000001], n;
string s;
int main() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<')
      a[i + 1] = 1;
    else if (s[i] == '{')
      a[i + 1] = 2;
    else if (s[i] == '[')
      a[i + 1] = 3;
    else if (s[i] == '(')
      a[i + 1] = 4;
    else if (s[i] == '>')
      a[i + 1] = -1;
    else if (s[i] == '}')
      a[i + 1] = -2;
    else if (s[i] == ']')
      a[i + 1] = -3;
    else if (s[i] == ')')
      a[i + 1] = -4;
  }
  long stt = 0, kq = 0;
  for (int i = 1; i <= n; i++) {
    if (stt == 0)
      if (a[i] < 0) {
        cout << "Impossible";
        return 0;
      } else {
        stt++;
        b[stt] = a[i];
      }
    else if (a[i] > 0) {
      stt++;
      b[stt] = a[i];
    } else {
      if (b[stt] + a[i] != 0) {
        kq++;
      }
      stt--;
    }
  }
  if (stt == 0)
    cout << kq;
  else
    cout << "Impossible";
}
