#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  stack<char> stk;
  map<char, char> m;
  m['('] = 'o', m['{'] = 'o', m['<'] = 'o', m['['] = 'o', m[')'] = 'c',
  m[']'] = 'c', m['>'] = 'c', m['}'] = 'c';
  for (int i = 0; i < n; i++) {
    if (stk.size() > 0 && m[stk.top()] == 'o' && m[s[i]] == 'c') {
      if (!((stk.top() == '{' && s[i] == '}') ||
            (stk.top() == '(' && s[i] == ')') ||
            (stk.top() == '<' && s[i] == '>') ||
            (stk.top() == '[' && s[i] == ']')))
        ans += 1;
      stk.pop();
    } else
      stk.push(s[i]);
  }
  if (stk.size() != 0)
    cout << "Impossible";
  else
    cout << ans;
  return 0;
}
