#include <bits/stdc++.h>
using namespace std;
string s;
int ans;
stack<char> st;
map<char, bool> open;
int main() {
  cin >> s;
  string op = "[{<(";
  for (int i = 0; op[i]; open[op[i++]] = 1)
    ;
  for (int i = 0; i < s.size(); i++) {
    if (open[s[i]])
      st.push(s[i]);
    else {
      if (!st.size()) return cout << "Impossible", 0;
      if (s[i] - st.top() != 2 && s[i] - st.top() != 1) ans++;
      st.pop();
    }
  }
  if (st.size())
    cout << "Impossible";
  else
    cout << ans;
  return 0;
}
