#include <bits/stdc++.h>
using namespace std;
#define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main () { GG;
string s;
cin>>s;	int n=s.size(),ans=0;
stack <char> st;	bool f=0;

for(int i=0;i<n;i++)
{	if(  (s[i]=='(' ) || (s[i]=='{' ) || (s[i]=='[' ) || (s[i]=='<' )   )
	st.push(s[i]);
	else if(st.size() != 0)
	{	if ( st.top()=='(' && s[i]==')')
		st.pop();
		else if(st.top()=='{' && s[i]=='}')
		st.pop();
		else if(st.top()=='[' && s[i]==']')
		st.pop();
		else if(st.top()=='<' && s[i]=='>')
		st.pop();
		
		else
		{ st.pop();
		  ans++;
		}
	}
	else
	{ f=1; break;
	}
}

if(f || st.size()!=0 )	cout<<"Impossible\n";
else	cout<<ans<<"\n";
return 0;}