#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
const int INF = 1E9;
char s[10 * maxn];
char st[10 * maxn];
int top = 0;
bool open(char c) {
  if (c == '{') return 1;
  if (c == '[') return 1;
  if (c == '(') return 1;
  if (c == '<') return 1;
  return 0;
}
bool eq(char c, char d) {
  if (c == '{' && d == '}') return 1;
  if (c == '(' && d == ')') return 1;
  if (c == '[' && d == ']') return 1;
  if (c == '<' && d == '>') return 1;
  return 0;
}
int solve() {
  gets(s);
  int n = strlen(s);
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (open(s[i]))
      st[top++] = s[i];
    else {
      if (top == 0) {
        printf("Impossible\n");
        return 0;
      }
      top--;
      if (!eq(st[top], s[i])) ans++;
    }
  if (top != 0)
    printf("Impossible\n");
  else
    printf("%d\n", ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  solve();
  return 0;
}
